Remove guidance against passing unique_ptr<T> by const&, closes #2240
Some checks are pending
build / build (push) Waiting to run
Deploy Jekyll with GitHub Pages dependencies preinstalled / build (push) Waiting to run
Deploy Jekyll with GitHub Pages dependencies preinstalled / deploy (push) Blocked by required conditions

This commit is contained in:
Herb Sutter
2024-12-19 09:50:45 -10:00
parent e738bcc73c
commit de1861cdbd

View File

@@ -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`
@@ -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