From 7763b97b52f75c12241d4cfd6709d8acc06705e6 Mon Sep 17 00:00:00 2001 From: Elias Kosunen Date: Fri, 9 Jun 2017 23:30:42 +0300 Subject: [PATCH] Add braces to for loop in P.1 example `for` with no `block-statement` as its `statement` is bad practice and should not be shown in an example. This example is meant to demonstrate code duplication and expessiveness, not to show poor usage of braces or lack thereof. --- CppCoreGuidelines.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 3d5dd87..b933031 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -486,11 +486,12 @@ The second version leaves the reader guessing and opens more possibilities for u cin >> val; // ... int index = -1; // bad - for (int i = 0; i < v.size(); ++i) + for (int i = 0; i < v.size(); ++i) { if (v[i] == val) { index = i; break; } + } // ... }