The loop variable should be a reference in order to effect the
modification of the array elements.
This commit is contained in:
Gabriel Dos Reis 2015-09-20 10:26:34 -07:00
parent e85995ed0b
commit f18b83a563

View File

@ -683,7 +683,7 @@ We could check earlier and improve the code:
void increment2(array_view<int> p)
{
for (int x : p) ++x;
for (int& x : p) ++x;
}
void use2(int m)