Skip to content

Commit

Permalink
Add #pNN anchors for P section
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter committed Feb 15, 2024
1 parent 631eccd commit acf08dd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions CppCoreGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Philosophical rules are generally not mechanically checkable.
However, individual rules reflecting these philosophical themes are.
Without a philosophical basis, the more concrete/specific/checkable rules lack rationale.

### <a name="Rp-direct"></a>P.1: Express ideas directly in code
### <a name="p1"></a><a name="Rp-direct"></a>P.1: Express ideas directly in code

##### Reason

Expand Down Expand Up @@ -563,7 +563,7 @@ Very hard in general.
* flag uses of casts (casts neuter the type system)
* detect code that mimics the standard library (hard)

### <a name="Rp-Cplusplus"></a>P.2: Write in ISO Standard C++
### <a name="p2"></a><a name="Rp-Cplusplus"></a>P.2: Write in ISO Standard C++

##### Reason

Expand Down Expand Up @@ -595,7 +595,7 @@ In such cases, control their (dis)use with an extension of these Coding Guidelin

Use an up-to-date C++ compiler (currently C++20 or C++17) with a set of options that do not accept extensions.

### <a name="Rp-what"></a>P.3: Express intent
### <a name="p3"></a><a name="Rp-what"></a>P.3: Express intent

##### Reason

Expand Down Expand Up @@ -661,7 +661,7 @@ Look for common patterns for which there are better alternatives

There is a huge scope for cleverness and semi-automated program transformation.

### <a name="Rp-typesafe"></a>P.4: Ideally, a program should be statically type safe
### <a name="p4"></a><a name="Rp-typesafe"></a>P.4: Ideally, a program should be statically type safe

##### Reason

Expand Down Expand Up @@ -691,7 +691,7 @@ For example:
* range errors -- use `span`
* narrowing conversions -- minimize their use and use `narrow` or `narrow_cast` (from the GSL) where they are necessary

### <a name="Rp-compile-time"></a>P.5: Prefer compile-time checking to run-time checking
### <a name="p5"></a><a name="Rp-compile-time"></a>P.5: Prefer compile-time checking to run-time checking

##### Reason

Expand Down Expand Up @@ -735,7 +735,7 @@ better
* Look for pointer arguments.
* Look for run-time checks for range violations.

### <a name="Rp-run-time"></a>P.6: What cannot be checked at compile time should be checkable at run time
### <a name="p6"></a><a name="Rp-run-time"></a>P.6: What cannot be checked at compile time should be checkable at run time

##### Reason

Expand Down Expand Up @@ -842,7 +842,7 @@ How do we transfer both ownership and all information needed for validating use?
* Flag (pointer, count)-style interfaces (this will flag a lot of examples that can't be fixed for compatibility reasons)
* ???

### <a name="Rp-early"></a>P.7: Catch run-time errors early
### <a name="p7"></a><a name="Rp-early"></a>P.7: Catch run-time errors early

##### Reason

Expand Down Expand Up @@ -959,7 +959,7 @@ The physical law for a jet (`e * e < x * x + y * y + z * z`) is not an invariant
* Look for structured data (objects of classes with invariants) being converted into strings
* ???

### <a name="Rp-leak"></a>P.8: Don't leak any resources
### <a name="p8"></a><a name="Rp-leak"></a>P.8: Don't leak any resources

##### Reason

Expand Down Expand Up @@ -1012,7 +1012,7 @@ Combine this with enforcement of [the type and bounds profiles](#SS-force) and y
* Look for naked `new` and `delete`
* Look for known resource allocating functions returning raw pointers (such as `fopen`, `malloc`, and `strdup`)

### <a name="Rp-waste"></a>P.9: Don't waste time or space
### <a name="p9"></a><a name="Rp-waste"></a>P.9: Don't waste time or space

##### Reason

Expand Down Expand Up @@ -1088,7 +1088,7 @@ Many more specific rules aim at the overall goals of simplicity and elimination
* Flag an unused return value from a user-defined non-defaulted postfix `operator++` or `operator--` function. Prefer using the prefix form instead. (Note: "User-defined non-defaulted" is intended to reduce noise. Review this enforcement if it's still too noisy in practice.)


### <a name="Rp-mutable"></a>P.10: Prefer immutable data to mutable data
### <a name="p10"></a><a name="Rp-mutable"></a>P.10: Prefer immutable data to mutable data

##### Reason

Expand All @@ -1099,7 +1099,7 @@ You can't have a data race on a constant.

See [Con: Constants and immutability](#S-const)

### <a name="Rp-library"></a>P.11: Encapsulate messy constructs, rather than spreading through the code
### <a name="p11"></a><a name="Rp-library"></a>P.11: Encapsulate messy constructs, rather than spreading through the code

##### Reason

Expand Down Expand Up @@ -1149,7 +1149,7 @@ This is a variant of the [subset of superset principle](#R0) that underlies thes
* Look for "messy code" such as complex pointer manipulation and casting outside the implementation of abstractions.


### <a name="Rp-tools"></a>P.12: Use supporting tools as appropriate
### <a name="p12"></a><a name="Rp-tools"></a>P.12: Use supporting tools as appropriate

##### Reason

Expand Down Expand Up @@ -1178,7 +1178,7 @@ Be careful not to become dependent on over-elaborate or over-specialized tool ch
Those can make your otherwise portable code non-portable.


### <a name="Rp-lib"></a>P.13: Use support libraries as appropriate
### <a name="p13"></a><a name="Rp-lib"></a>P.13: Use support libraries as appropriate

##### Reason

Expand Down

0 comments on commit acf08dd

Please sign in to comment.