mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
clarification of F.42
This commit is contained in:
@@ -2649,10 +2649,6 @@ Note that pervasive use of `shared_ptr` has a cost (atomic operations on the `sh
|
|||||||
That's what pointers are good for.
|
That's what pointers are good for.
|
||||||
Returning a `T*` to transfer ownership is a misuse.
|
Returning a `T*` to transfer ownership is a misuse.
|
||||||
|
|
||||||
##### Note
|
|
||||||
|
|
||||||
Do not return a pointer to something that is not in the caller's scope.
|
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
Node* find(Node* t, const string& s) // find s in a binary tree of Nodes
|
Node* find(Node* t, const string& s) // find s in a binary tree of Nodes
|
||||||
@@ -2670,6 +2666,10 @@ Importantly, that does not imply a transfer of ownership of the pointed-to objec
|
|||||||
|
|
||||||
Positions can also be transferred by iterators, indices, and references.
|
Positions can also be transferred by iterators, indices, and references.
|
||||||
|
|
||||||
|
##### Note
|
||||||
|
|
||||||
|
Do not return a pointer to something that is not in the caller's scope; see [F.43](#Rf-dangle).
|
||||||
|
|
||||||
##### Example, bad
|
##### Example, bad
|
||||||
|
|
||||||
int* f()
|
int* f()
|
||||||
|
|||||||
Reference in New Issue
Block a user