C++11C++14C++17IteratorsLearn C++

Range-for-statement in Modern C++

Since C++11 there are elegant way to access each element of a containers (or, more generally, sequences) – so called range-for-statement. The syntaxes are follow: template<class Container> void foo(Container& container) { for (auto element : container); // (1) for (const auto element : container); // (2) for (auto& element : container); // (3) for…
Read more