mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
clarification of F.42
This commit is contained in:
parent
518304ed63
commit
729db042f1
|
@ -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.
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
##### Note
|
||||
|
||||
Do not return a pointer to something that is not in the caller's scope; see [F.43](#Rf-dangle).
|
||||
|
||||
##### Example, bad
|
||||
|
||||
int* f()
|
||||
|
|
Loading…
Reference in New Issue
Block a user