From d674cd7debcff35ab4b38e6a95fec560d151b4b7 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Wed, 4 Mar 2015 17:38:12 +0100 Subject: [PATCH] core: add make_shared(T&&) overload Allows for code like this: auto p = make_shared(object()); --- core/shared_ptr.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/shared_ptr.hh b/core/shared_ptr.hh index 53e6ec1404..032d001775 100644 --- a/core/shared_ptr.hh +++ b/core/shared_ptr.hh @@ -69,6 +69,9 @@ lw_shared_ptr make_lw_shared(T& a); template shared_ptr make_shared(A&&... a); +template +shared_ptr make_shared(T&& a); + template shared_ptr static_pointer_cast(const shared_ptr& p); @@ -375,6 +378,9 @@ public: template friend shared_ptr make_shared(A&&... a); + template + friend shared_ptr make_shared(U&& a); + template friend shared_ptr static_pointer_cast(const shared_ptr& p); @@ -424,6 +430,14 @@ make_shared(A&&... a) { return helper::make(std::forward(a)...); } +template +inline +shared_ptr +make_shared(T&& a) { + using helper = shared_ptr_make_helper, T>::value>; + return helper::make(std::forward(a)); +} + template inline shared_ptr