From c4431e1c38a773c5784d33ba368a39b86bb33681 Mon Sep 17 00:00:00 2001 From: Anthony Calandra Date: Sun, 25 Jun 2017 15:07:35 -0400 Subject: [PATCH] Typo in std::make_shared section. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68e2760..3b31b55 100644 --- a/README.md +++ b/README.md @@ -1254,9 +1254,9 @@ These containers maintain average constant-time complexity for search, insert, a ```c++ foo(std::shared_ptr{ new T{} }, function_that_throws(), std::shared_ptr{ new T{} }); ``` -The compiler is free to call `new T{}`, then `function_that_throws()`, and so on... Since we have allocated data on the heap in the first construction of a `T`, we have introduced a leak here. With `std::make_unique`, we are given exception-safety: +The compiler is free to call `new T{}`, then `function_that_throws()`, and so on... Since we have allocated data on the heap in the first construction of a `T`, we have introduced a leak here. With `std::make_shared`, we are given exception-safety: ```c++ -foo(std::make_unique(), function_that_throws(), std::make_unique()); +foo(std::make_shared(), function_that_throws(), std::make_shared()); ``` * Prevents having to do two allocations. When calling `std::shared_ptr{ new T{} }`, we have to allocate memory for `T`, then in the shared pointer we have to allocate memory for the control block within the pointer.