diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 76a4fe6..2f843df 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -9223,7 +9223,7 @@ Instead, use a local variable: ##### Enforcement * (Moderate) Warn if an object is allocated and then deallocated on all paths within a function. Suggest it should be a local `auto` stack object instead. -* (Simple) Warn if a local `Unique_ptr` or `Shared_ptr` is not moved, copied, reassigned or `reset` before its lifetime ends. +* (Simple) Warn if a local `Unique_pointer` or `Shared_pointer` is not moved, copied, reassigned or `reset` before its lifetime ends. ### R.6: Avoid non-`const` global variables @@ -9484,7 +9484,7 @@ This is more efficient: ##### Enforcement -(Simple) Warn if a function uses a `Shared_ptr` with an object allocated within the function, but never returns the `Shared_ptr` or passes it to a function requiring a `Shared_ptr&`. Suggest using `unique_ptr` instead. +(Simple) Warn if a function uses a `Shared_pointer` with an object allocated within the function, but never returns the `Shared_pointer` or passes it to a function requiring a `Shared_pointer&`. Suggest using `unique_ptr` instead. ### R.22: Use `make_shared()` to make `shared_ptr`s @@ -9646,9 +9646,9 @@ Any type (including primary template or specialization) that overloads unary `*` } Both cases are an error under the [`sharedptrparam` guideline](#Rr-smartptrparam): -`p` is a `Shared_ptr`, but nothing about its sharedness is used here and passing it by value is a silent pessimization; +`p` is a `Shared_pointer`, but nothing about its sharedness is used here and passing it by value is a silent pessimization; these functions should accept a smart pointer only if they need to participate in the widget's lifetime management. Otherwise they should accept a `widget*`, if it can be `nullptr`. Otherwise, and ideally, the function should accept a `widget&`. -These smart pointers match the `Shared_ptr` concept, so these guideline enforcement rules work on them out of the box and expose this common pessimization. +These smart pointers match the `Shared_pointer` concept, so these guideline enforcement rules work on them out of the box and expose this common pessimization. ### R.32: Take a `unique_ptr` parameter to express that a function assumes ownership of a `widget` @@ -9668,8 +9668,8 @@ Using `unique_ptr` in this way both documents and enforces the function call's o ##### Enforcement -* (Simple) Warn if a function takes a `Unique_ptr` 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_ptr` parameter by reference to `const`. Suggest taking a `const T*` or `const T&` instead. +* (Simple) Warn if a function takes a `Unique_pointer` 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` parameter by reference to `const`. Suggest taking a `const T*` or `const T&` instead. ### R.33: Take a `unique_ptr&` parameter to express that a function reseats the`widget` @@ -9691,8 +9691,8 @@ Using `unique_ptr` in this way both documents and enforces the function call's r ##### Enforcement -* (Simple) Warn if a function takes a `Unique_ptr` 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_ptr` parameter by reference to `const`. Suggest taking a `const T*` or `const T&` instead. +* (Simple) Warn if a function takes a `Unique_pointer` 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` parameter by reference to `const`. Suggest taking a `const T*` or `const T&` instead. ### R.34: Take a `shared_ptr` parameter to express that a function is part owner @@ -9710,9 +9710,9 @@ This makes the function's ownership sharing explicit. ##### Enforcement -* (Simple) Warn if a function takes a `Shared_ptr` 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 `Shared_ptr` by value or by reference to `const` and does not copy or move it to another `Shared_ptr` on at least one code path. Suggest taking a `T*` or `T&` instead. -* (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr` by rvalue reference. Suggesting taking it by value instead. +* (Simple) Warn if a function takes a `Shared_pointer` 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 `Shared_pointer` by value or by reference to `const` and does not copy or move it to another `Shared_pointer` on at least one code path. Suggest taking a `T*` or `T&` instead. +* (Simple) ((Foundation)) Warn if a function takes a `Shared_pointer` by rvalue reference. Suggesting taking it by value instead. ### R.35: Take a `shared_ptr&` parameter to express that a function might reseat the shared pointer @@ -9734,9 +9734,9 @@ This makes the function's reseating explicit. ##### Enforcement -* (Simple) Warn if a function takes a `Shared_ptr` 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 `Shared_ptr` by value or by reference to `const` and does not copy or move it to another `Shared_ptr` on at least one code path. Suggest taking a `T*` or `T&` instead. -* (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr` by rvalue reference. Suggesting taking it by value instead. +* (Simple) Warn if a function takes a `Shared_pointer` 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 `Shared_pointer` by value or by reference to `const` and does not copy or move it to another `Shared_pointer` on at least one code path. Suggest taking a `T*` or `T&` instead. +* (Simple) ((Foundation)) Warn if a function takes a `Shared_pointer` by rvalue reference. Suggesting taking it by value instead. ### R.36: Take a `const shared_ptr&` parameter to express that it might retain a reference count to the object ??? @@ -9754,9 +9754,9 @@ This makes the function's ??? explicit. ##### Enforcement -* (Simple) Warn if a function takes a `Shared_ptr` 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 `Shared_ptr` by value or by reference to `const` and does not copy or move it to another `Shared_ptr` on at least one code path. Suggest taking a `T*` or `T&` instead. -* (Simple) ((Foundation)) Warn if a function takes a `Shared_ptr` by rvalue reference. Suggesting taking it by value instead. +* (Simple) Warn if a function takes a `Shared_pointer` 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 `Shared_pointer` by value or by reference to `const` and does not copy or move it to another `Shared_pointer` on at least one code path. Suggest taking a `T*` or `T&` instead. +* (Simple) ((Foundation)) Warn if a function takes a `Shared_pointer` by rvalue reference. Suggesting taking it by value instead. ### R.37: Do not pass a pointer or reference obtained from an aliased smart pointer @@ -9817,7 +9817,7 @@ The fix is simple -- take a local copy of the pointer to "keep a ref count" for ##### Enforcement -* (Simple) Warn if a pointer or reference obtained from a smart pointer variable (`Unique_ptr` or `Shared_ptr`) that is nonlocal, or that is local but potentially aliased, is used in a function call. If the smart pointer is a `Shared_ptr` then suggest taking a local copy of the smart pointer and obtain a pointer or reference from that instead. +* (Simple) Warn if a pointer or reference obtained from a smart pointer variable (`Unique_pointer` or `Shared_pointer`) that is nonlocal, or that is local but potentially aliased, is used in a function call. If the smart pointer is a `Shared_pointer` then suggest taking a local copy of the smart pointer and obtain a pointer or reference from that instead. # ES: Expressions and statements @@ -20653,8 +20653,8 @@ Most of the concepts below are defined in [the Ranges TS](http://www.open-std.or ### GSL.ptr: Smart pointer concepts * `Pointer` // A type with `*`, `->`, `==`, and default construction (default construction is assumed to set the singular "null" value) -* `Unique_ptr` // A type that matches `Pointer`, is movable, and is not copyable -* `Shared_ptr` // A type that matches `Pointer`, and is copyable +* `Unique_pointer` // A type that matches `Pointer`, is movable, and is not copyable +* `Shared_pointer` // A type that matches `Pointer`, and is copyable # NL: Naming and layout rules