clarification of F.42

This commit is contained in:
Bjarne Stroustrup 2015-12-05 21:25:46 -05:00
parent 518304ed63
commit 729db042f1

View File

@ -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()