P.3: Fixed an inaccurate description of for (const auto& x : v).

This commit is contained in:
Michael Park 2015-12-10 07:45:42 -05:00
parent ccacbd6d54
commit 6e39add6a6

View File

@ -464,7 +464,7 @@ Better:
for (const auto& x : v) { /* do something with x */ } for (const auto& x : v) { /* do something with x */ }
Now, there is no explicit mention of the iteration mechanism, and the loop operates on a copy of elements so that accidental modification cannot happen. If modification is desired, say so: Now, there is no explicit mention of the iteration mechanism, and the loop operates on a reference to `const` elements so that accidental modification cannot happen. If modification is desired, say so:
for (auto& x : v) { /* do something with x */ } for (auto& x : v) { /* do something with x */ }