You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CppCoreGuidelines.md
+29-29Lines changed: 29 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -10694,7 +10694,7 @@ Application concepts are easier to reason about.
10694
10694
10695
10695
???
10696
10696
10697
-
###### Note
10697
+
##### Note
10698
10698
10699
10699
With the exception of `async()`, the standard-library facilities are low-level, machine-oriented, threads-and-lock level.
10700
10700
This is a necessary foundation, but we have to try to raise the level of abstrcation: for productivity, for reliability, and for performance.
@@ -11117,7 +11117,7 @@ A `thread` that has not been `detach()`ed when it is destroyed terminates the pr
11117
11117
11118
11118
### <a name="RRconc-pass"></a>CP.30: Do not pass pointers to local variables to non-`raii_thread's
11119
11119
11120
-
###### Reason
11120
+
##### Reason
11121
11121
11122
11122
In general, you cannot know whether a non-`raii_thread` will outlife your thread (so that those pointers will become invalid.
11123
11123
@@ -11264,7 +11264,7 @@ Instead, we could have a set of pre-created worker threads processing the messag
11264
11264
raii_thread w4 {worker};
11265
11265
}
11266
11266
11267
-
###### Note
11267
+
##### Note
11268
11268
11269
11269
If you system has a good thread pool, use it.
11270
11270
If your system has a good message queue, use it.
@@ -11662,11 +11662,11 @@ For example, reading `clock` twice will often yield two different values, so the
11662
11662
11663
11663
`clock` is `const` because the program should not try to write to `clock`.
11664
11664
11665
-
###### Note
11665
+
##### Note
11666
11666
11667
11667
Unless you are writing the lowest level code manipulating hardware directly, consider `volatile` an esoteric feature that is best avoided.
11668
11668
11669
-
###### Example
11669
+
##### Example
11670
11670
11671
11671
Usually C++ code receives `volatile` memory that is owned Elsewhere (hardware or another language):
11672
11672
@@ -12462,7 +12462,7 @@ For example:
12462
12462
One reason to prefer a specific return type is to have names for its members, rather than the somewhat cryptic `first` and `second`
12463
12463
and to avoid confusion with other uses of `std::pair`.
12464
12464
12465
-
###### Example
12465
+
##### Example
12466
12466
12467
12467
In general, you must clean up before an error exit.
12468
12468
This can be messy:
@@ -13081,18 +13081,18 @@ Flag template type arguments without concepts
13081
13081
13082
13082
##### Reason
13083
13083
13084
-
"Standard" concepts (as provided by the [GSL]#S-GSL), the ISO concepts TS, [Ranges TS](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4569.pdf), and hopefully soon the ISO standard itself)
13084
+
"Standard" concepts (as provided by the [GSL](#S-GSL) and the [Ranges TS](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4569.pdf), and hopefully soon the ISO standard itself)
13085
13085
saves us the work of thinking up our own concepts, are better thought out than we can manage to do in a hurry, and improves interoperability.
13086
13086
13087
13087
##### Note
13088
13088
13089
13089
Unless you are creating a new generic library, most of the concepts you need will already be defined by the standard library.
@@ -13256,9 +13256,9 @@ Helps implementers and maintainers.
13256
13256
13257
13257
This is a specific variant of the gerenral rule that [a concept mist make semantic sense](#Rt-low).
13258
13258
13259
-
##### Example, bad
13259
+
##### Example, bad (using TS concepts)
13260
13260
13261
-
template<typename T> Subtractable = requires(T a, T, b) { a-b; };
13261
+
template<typename T> concept Subtractable = requires(T a, T, b) { a-b; };
13262
13262
13263
13263
This makes no semantic sense.
13264
13264
You need at least `+` to make `-` meaningful and useful.
@@ -13342,7 +13342,7 @@ A meaningful/useful concept has a semantic meaning.
13342
13342
Expressing these semantics in an informal, semi-formal, or formal way makes the concept comprehensible to readers and the effort to express it can catch conceptual errors.
13343
13343
Specifying semantics is a powerful design tool.
13344
13344
13345
-
##### Example
13345
+
##### Example (using TS concepts)
13346
13346
13347
13347
template<typename T>
13348
13348
// The operators +, -, *, and / for a number are assumed to follow the usual mathematical rules
@@ -13371,7 +13371,7 @@ Once language support is available, the `//` in front of the axiom can be remove
13371
13371
13372
13372
The GSL concepts have well defined semantics; see the Palo Alto TR and the Ranges TS.
13373
13373
13374
-
##### Exception
13374
+
##### Exception (using TS concepts)
13375
13375
13376
13376
Early versions of a new "concept" still under development will often just define simple sets of constraints without a well-specified semantics.
13377
13377
Finding good semantics can take effort and time.
@@ -13403,7 +13403,7 @@ Each new use case may require such an incomplete concepts to be improved.
13403
13403
13404
13404
Otherwise they cannot be distinguished automatically by the compiler.
13405
13405
13406
-
##### Example
13406
+
##### Example (using TS concepts)
13407
13407
13408
13408
template<typename I>
13409
13409
concept bool Input_iter = requires (I iter) { ++iter; };
@@ -13426,7 +13426,7 @@ If two concepts have exactly the same requirements, they are logically equivalen
13426
13426
13427
13427
Two concepts requiring the same syntax but having different semantics leads to ambiguity unless the programmer differentiates them.
13428
13428
13429
-
##### Example
13429
+
##### Example (using TS concepts)
13430
13430
13431
13431
template<typename I> // iterator providing random access
13432
13432
concept bool RA_iter = ...;
@@ -13439,7 +13439,7 @@ The programmer (in a library) must define `is_contiguous` (a trait) appropriatel
13439
13439
13440
13440
Wrapping a tag class into a concept leads to a simpler expression of this idea:
0 commit comments