Skip to content

Commit

Permalink
Remove guidance against passing unique_ptr<T> by const&, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter committed Dec 19, 2024
1 parent e738bcc commit de1861c
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions CppCoreGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -9993,14 +9993,9 @@ Using `unique_ptr` in this way both documents and enforces the function call's o

void uses(widget*); // just uses the widget

##### Example, bad

void thinko(const unique_ptr<widget>&); // usually not what you want

##### Enforcement

* (Simple) Warn if a function takes a `Unique_pointer<T>` parameter by lvalue reference and does not either assign to it or call `reset()` on it on at least one code path. Suggest taking a `T*` or `T&` instead.
* (Simple) ((Foundation)) Warn if a function takes a `Unique_pointer<T>` parameter by reference to `const`. Suggest taking a `const T*` or `const T&` instead.

### <a name="Rr-reseat"></a>R.33: Take a `unique_ptr<widget>&` parameter to express that a function reseats the `widget`

Expand All @@ -10016,14 +10011,9 @@ Using `unique_ptr` in this way both documents and enforces the function call's r

void reseat(unique_ptr<widget>&); // "will" or "might" reseat pointer

##### Example, bad

void thinko(const unique_ptr<widget>&); // usually not what you want

##### Enforcement

* (Simple) Warn if a function takes a `Unique_pointer<T>` parameter by lvalue reference and does not either assign to it or call `reset()` on it on at least one code path. Suggest taking a `T*` or `T&` instead.
* (Simple) ((Foundation)) Warn if a function takes a `Unique_pointer<T>` parameter by reference to `const`. Suggest taking a `const T*` or `const T&` instead.

### <a name="Rr-sharedptrparam-owner"></a>R.34: Take a `shared_ptr<widget>` parameter to express shared ownership

Expand Down

0 comments on commit de1861c

Please sign in to comment.