From 2839c87890af4816d54a0592c4592234203c6c71 Mon Sep 17 00:00:00 2001 From: Bjarne Stroustrup Date: Sun, 17 Sep 2017 17:54:33 -0400 Subject: [PATCH] add example to R.20 addresses #1015 --- CppCoreGuidelines.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 273df9e..e1eab29 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1,6 +1,6 @@ # C++ Core Guidelines -August 11, 2017 +September 17, 2017 Editors: @@ -9103,6 +9103,8 @@ Consider: X* p1 { new X }; // see also ??? unique_ptr p2 { new X }; // unique ownership; see also ??? shared_ptr p3 { new X }; // shared ownership; see also ??? + auto p4 = make_unique(); // unique_ownership, preferable to the explicit use "new" + auto p5 = make_shared(); // shared ownership, preferable to the explicit use "new" } This will leak the object used to initialize `p1` (only).