add example to R.20

addresses #1015
This commit is contained in:
Bjarne Stroustrup 2017-09-17 17:54:33 -04:00
parent b87d21b662
commit 2839c87890

View File

@ -1,6 +1,6 @@
# <a name="main"></a>C++ Core Guidelines
August 11, 2017
September 17, 2017
Editors:
@ -9103,6 +9103,8 @@ Consider:
X* p1 { new X }; // see also ???
unique_ptr<T> p2 { new X }; // unique ownership; see also ???
shared_ptr<T> p3 { new X }; // shared ownership; see also ???
auto p4 = make_unique<X>(); // unique_ownership, preferable to the explicit use "new"
auto p5 = make_shared<X>(); // shared ownership, preferable to the explicit use "new"
}
This will leak the object used to initialize `p1` (only).