Skip to content

Commit

Permalink
Add note about pointerlike indirections, and remove incorrect destruc…
Browse files Browse the repository at this point in the history
…tor note

Closes #2183
Closes #2188
  • Loading branch information
hsutter committed Apr 14, 2024
1 parent 4f723b0 commit 6c68bf8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions CppCoreGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,7 @@ value) of any assignment operator.

Returning a local variable implicitly moves it anyway.
An explicit `std::move` is always a pessimization, because it prevents Return Value Optimization (RVO),
which can eliminate the move completely.
which can eliminate the move completely.

##### Example, bad

Expand Down Expand Up @@ -5096,10 +5096,6 @@ There are two general categories of classes that need a user-defined destructor:

The default destructor does it better, more efficiently, and can't get it wrong.

##### Note

If the default destructor is needed, but its generation has been suppressed (e.g., by defining a move constructor), use `=default`.

##### Enforcement

Look for likely "implicit resources", such as pointers and references. Look for classes with destructors even though all their data members have destructors.
Expand Down Expand Up @@ -12682,6 +12678,10 @@ wrong results, or memory corruption.

##### Note

By pointer here we mean any indirection to an object, including equivalently an iterator or view.

##### Note

This rule is an obvious and well-known language rule, but can be hard to follow.
It takes good coding style, library support, and static analysis to eliminate violations without major overhead.
This is a major part of the discussion of [C++'s model for type- and resource-safety](#Stroustrup15).
Expand Down

0 comments on commit 6c68bf8

Please sign in to comment.