diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index ad747ff..1e22656 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -12595,10 +12595,8 @@ Readability. Error prevention. Efficiency. cout << f(v, &v[i]) << '\n'; for (gsl::index i = 0; i < v.size(); ++i) { // body messes with loop variable: can't be a range-for - if (i % 2 == 0) - continue; // skip even elements - else - cout << v[i] << '\n'; + if (i % 2 != 0) + cout << v[i] << '\n'; // output odd elements } A human or a good static analyzer might determine that there really isn't a side effect on `v` in `f(v, &v[i])` so that the loop can be rewritten. @@ -20386,7 +20384,7 @@ In particular, the single-return rule makes it harder to concentrate error check { if (x < 0) return "negative"; - else if (x > 0) + if (x > 0) return "positive"; return "zero"; }