|
|
|
@ -12595,10 +12595,8 @@ Readability. Error prevention. Efficiency.
|
|
|
|
cout << f(v, &v[i]) << '\n';
|
|
|
|
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
|
|
|
|
for (gsl::index i = 0; i < v.size(); ++i) { // body messes with loop variable: can't be a range-for
|
|
|
|
if (i % 2 == 0)
|
|
|
|
if (i % 2 != 0)
|
|
|
|
continue; // skip even elements
|
|
|
|
cout << v[i] << '\n'; // output odd elements
|
|
|
|
else
|
|
|
|
|
|
|
|
cout << v[i] << '\n';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
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)
|
|
|
|
if (x < 0)
|
|
|
|
return "negative";
|
|
|
|
return "negative";
|
|
|
|
else if (x > 0)
|
|
|
|
if (x > 0)
|
|
|
|
return "positive";
|
|
|
|
return "positive";
|
|
|
|
return "zero";
|
|
|
|
return "zero";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|