mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 04:44:34 +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.
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user