Skip to content

Commit f92c1c2

Browse files
committed
Tweaked #1551
To adjust example comment and Enforcement per PR #1551 comments
1 parent 164c0b3 commit f92c1c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

CppCoreGuidelines.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12718,7 +12718,7 @@ consider `gsl::finally()` as a cleaner and more reliable alternative to `goto ex
1271812718

1271912719
Often, a loop that requires a `break` is a good candidate for a function (algorithm), in which case the `break` becomes a `return`.
1272012720

12721-
//BAD: break inside loop
12721+
//Original code: break inside loop
1272212722
void use1(){
1272312723
std::vector<T> vec = {/* initialized with some values */};
1272412724
T value;
@@ -12731,7 +12731,7 @@ Often, a loop that requires a `break` is a good candidate for a function (algori
1273112731
/* then do something with value */
1273212732
}
1273312733

12734-
//GOOD: create a function and return inside loop
12734+
//BETTER: create a function and return inside loop
1273512735
T search(const std::vector<T> &vec){
1273612736
for(const T &item : vec){
1273712737
if(/* some condition*/) return item;
@@ -12767,7 +12767,7 @@ If you really need to break out a loop, a `break` is typically better than alter
1276712767

1276812768
##### Enforcement
1276912769

12770-
Flag any use of `break` and `continue` inside a loop.
12770+
???
1277112771

1277212772
### <a name="Res-break"></a>ES.78: Don't rely on implicit fallthrough in `switch` statements
1277312773

0 commit comments

Comments
 (0)