From 729db042f17a1d03134b2097f5214a0036b985dc Mon Sep 17 00:00:00 2001 From: Bjarne Stroustrup Date: Sat, 5 Dec 2015 21:25:46 -0500 Subject: [PATCH] clarification of F.42 --- CppCoreGuidelines.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 1394206..86a6948 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -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()