What is the correct way of using C++11’s range-based for?

What syntax should be used? for (auto elem : container),
or for (auto& elem : container) or for (const auto& elem : container)?
Or some other?

4 Answers
4

Leave a Reply

Your email address will not be published. Required fields are marked *