From e41f3f85f89569a03f45703b27078027e4d0a974 Mon Sep 17 00:00:00 2001 From: eyal bari Date: Tue, 3 May 2016 11:02:33 +0300 Subject: [PATCH] fix mixed index / iterator loop condition replaced end with size --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 5babd98..082bbf5 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -8166,7 +8166,7 @@ Conventional short, local names increase readability: template // good void print(ostream& os, const vector& v) { - for (int i = 0; i < v.end(); ++i) + for (int i = 0; i < v.size(); ++i) os << v[i] << '\n'; } @@ -8176,7 +8176,7 @@ An index is conventionally called `i` and there is no hint about the meaning of void print(ostream& target_stream, const vector& current_vector) { for (int current_element_index = 0; - current_element_index < current_vector.end(); + current_element_index < current_vector.size(); ++current_element_index ) target_stream << current_vector[i] << '\n';