I have the following code:
for (auto it = _locations.locations().begin(); it != _locations.locations().end(); ++it)
// Do something
I wanted to replace it with
for (const auto& location: _locations.locations())
// Do something
but then realized I don't know how it's going to work. Will the locations() method be called each iteration, or will the result of the container expression evaluation be "cached" locally, resulting in only one locations() call? Does the standard define this behavior one way or the other?
auto && __range = range_expression ;line in the "Explanation" pseudocode.