From 9bc1644e64accd8020e2826e0f2075b5582577d8 Mon Sep 17 00:00:00 2001 From: "sv_91@inbox.ru" Date: Fri, 11 Oct 2019 09:22:00 +0300 Subject: [PATCH] Corrections constructor --- safe_ptr.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/safe_ptr.h b/safe_ptr.h index c0c30f9..cee3f0c 100644 --- a/safe_ptr.h +++ b/safe_ptr.h @@ -82,9 +82,18 @@ namespace sf { template friend class std::shared_lock; // C++14 #endif + private: + + safe_ptr(std::shared_ptr &&ptr, std::shared_ptr &&mtx_ptr) + : ptr(std::move(ptr)) + , mtx_ptr(std::move(mtx_ptr)) + {} + public: template - safe_ptr(Args... args) : ptr(std::make_shared(args...)), mtx_ptr(std::make_shared()) {} + static safe_ptr make_safe(Args&&... args) { + return safe_ptr(std::make_shared(std::forward(args)...), std::make_shared()); + } auto_lock_t operator -> () { return auto_lock_t(get_obj_ptr(), *get_mtx_ptr()); } auto_lock_obj_t operator * () { return auto_lock_obj_t(get_obj_ptr(), *get_mtx_ptr()); }