mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
fixed a typos because of zero-based indexing
Another misunderstanding: how container can be modified (side-effect in a call of `f(&v[i])` ) if we passing only an address to element, not a address to container?
This commit is contained in:
parent
ff78f166b5
commit
e238597f6c
@ -8247,10 +8247,10 @@ Readability. Error prevention. Efficiency.
|
||||
for (int i = 1; i < v.size(); ++i) // touches two elements: can't be a range-for
|
||||
cout << v[i] + v[i-1] << '\n';
|
||||
|
||||
for (int i = 1; i < v.size(); ++i) // possible side-effect: can't be a range-for
|
||||
for (int i = 0; i < v.size(); ++i) // possible side-effect: can't be a range-for
|
||||
cout << f(&v[i]) << '\n';
|
||||
|
||||
for (int i = 1; i < v.size(); ++i) { // body messes with loop variable: can't be a range-for
|
||||
for (int i = 0; i < v.size(); ++i) { // body messes with loop variable: can't be a range-for
|
||||
if (i % 2)
|
||||
++i; // skip even elements
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user