Range-for-statement in Modern C++
December 12, 2020
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…