\r
safe_ptr() : impl_(std::make_shared<T>()){} \r
\r
- safe_ptr(const safe_ptr<T>& other) : impl_(other.impl_){} // noexcept\r
- safe_ptr(safe_ptr<T>&& other) : impl_(std::move(other.impl_)){}\r
+ safe_ptr(const safe_ptr& other) : impl_(other.impl_){} // noexcept\r
+ safe_ptr(safe_ptr&& other) : impl_(std::move(other.impl_)){}\r
\r
template<typename U>\r
safe_ptr(const safe_ptr<U>& other, typename std::enable_if<std::is_convertible<U*, T*>::value, void*>::type = 0) : impl_(other.impl_){} // noexcept\r
}\r
\r
template<typename U>\r
- typename std::enable_if<std::is_convertible<U*, T*>::value, safe_ptr<T>&>::type\r
+ typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr&>::type\r
operator=(const safe_ptr<U>& other)\r
{\r
- safe_ptr<T> temp(other);\r
- temp.swap(*this);\r
+ safe_ptr(other).swap(*this);\r
+ return *this;\r
+ }\r
+\r
+ template<typename U>\r
+ typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr&>::type\r
+ operator=(safe_ptr<U>&& other)\r
+ {\r
+ safe_ptr(std::move(other)).swap(*this);\r
return *this;\r
}\r
\r
template <typename U>\r
- typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr<T>&>::type\r
+ typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr&>::type\r
operator=(U&& impl)\r
{\r
- safe_ptr<T> temp(std::forward<T>(impl));\r
+ safe_ptr temp(std::forward<T>(impl));\r
temp.swap(*this);\r
return *this;\r
}\r
operator const std::shared_ptr<T>&() const { return impl_;} // noexcept\r
\r
template<class U>\r
- bool owner_before(const safe_ptr<T>& ptr){ return impl_.owner_before(ptr.impl_); } // noexcept\r
+ bool owner_before(const safe_ptr& ptr){ return impl_.owner_before(ptr.impl_); } // noexcept\r
\r
template<class U>\r
bool owner_before(const std::shared_ptr<U>& ptr){ return impl_.owner_before(ptr); } // noexcept\r