Skip to content

Commit 8e82f0a

Browse files
committed
Merge pull request #603 from royalbee/patch-1
ES.7 fix mixed index / iterator loop condition
2 parents 2f0fab5 + e41f3f8 commit 8e82f0a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CppCoreGuidelines.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8166,7 +8166,7 @@ Conventional short, local names increase readability:
81668166
template<typename T> // good
81678167
void print(ostream& os, const vector<T>& v)
81688168
{
8169-
for (int i = 0; i < v.end(); ++i)
8169+
for (int i = 0; i < v.size(); ++i)
81708170
os << v[i] << '\n';
81718171
}
81728172

@@ -8176,7 +8176,7 @@ An index is conventionally called `i` and there is no hint about the meaning of
81768176
void print(ostream& target_stream, const vector<Element_type>& current_vector)
81778177
{
81788178
for (int current_element_index = 0;
8179-
current_element_index < current_vector.end();
8179+
current_element_index < current_vector.size();
81808180
++current_element_index
81818181
)
81828182
target_stream << current_vector[i] << '\n';

0 commit comments

Comments
 (0)