5 ms·
None of what you're saying is true though. Range based for loops were introduced in C++11 (technically C++11 was published in 2011, but almost all compilers su
by Kranar 4y ago
None of what you're saying is true though.
Range based for loops were introduced in C++11 (technically C++11 was published in 2011, but almost all compilers supported this way back in 2008-2009) and it's also nothing more than syntactic sugar. In order to provide support for a type T you need the following functions, which can be free functions or member functions:
begin(T&)
end(T&)
++(decltype(begin(T&)))
The only hack I can think of related to your post is that if T is an array, it uses the free functions std::begin and std::end which are overloaded to work with C arrays.