]> git.sesse.net Git - casparcg/blobdiff - common/memory/safe_ptr.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / common / memory / safe_ptr.h
index 346455d1bdc90acf3db7f0960d89d73bbe1925b1..e4269e69bd2166f96f984fb8287e930b77aafa7a 100644 (file)
@@ -103,11 +103,20 @@ public:
                return *this;\r
        }\r
 \r
-       T& operator*() const { return *impl_.get();}  // noexcept\r
+       T& operator*() const // noexcept\r
+       {\r
+               return *impl_.get();\r
+       } \r
 \r
-       T* operator->() const { return impl_.get();}  // noexcept\r
+       T* operator->() const // noexcept\r
+       {\r
+               return impl_.get();\r
+       } \r
 \r
-       T* get() const { return impl_.get();}  // noexcept\r
+       T* get() const // noexcept\r
+       {\r
+               return impl_.get();\r
+       }  \r
 \r
        bool unique() const { return impl_.unique();}  // noexcept\r
 \r
@@ -127,12 +136,36 @@ public:
        D* get_deleter(safe_ptr<U> const& ptr) { return impl_.get_deleter(); }  // noexcept\r
 };\r
 \r
+template<class T, class U>\r
+bool operator==(const std::shared_ptr<T>& a, const safe_ptr<U>& b)  // noexcept\r
+{\r
+       return a.get() == b.get();\r
+}\r
+\r
+template<class T, class U>\r
+bool operator==(const safe_ptr<T>& a, const std::shared_ptr<U>& b)  // noexcept\r
+{\r
+       return a.get() == b.get();\r
+}\r
+\r
 template<class T, class U>\r
 bool operator==(const safe_ptr<T>& a, const safe_ptr<U>& b)  // noexcept\r
 {\r
        return a.get() == b.get();\r
 }\r
 \r
+template<class T, class U>\r
+bool operator!=(const std::shared_ptr<T>& a, const safe_ptr<U>& b)  // noexcept\r
+{\r
+       return a.get() != b.get();\r
+}\r
+\r
+template<class T, class U>\r
+bool operator!=(const safe_ptr<T>& a, const std::shared_ptr<U>& b)  // noexcept\r
+{\r
+       return a.get() != b.get();\r
+}\r
+\r
 template<class T, class U>\r
 bool operator!=(const safe_ptr<T>& a, const safe_ptr<U>& b) // noexcept\r
 {\r
@@ -250,4 +283,10 @@ safe_ptr<T> make_safe(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4)
        return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2), std::forward<P3>(p3), std::forward<P4>(p4)));\r
 }\r
 \r
+template<typename T, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5>\r
+safe_ptr<T> make_safe(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4, P5&& p5)\r
+{\r
+       return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2), std::forward<P3>(p3), std::forward<P4>(p4), std::forward<P5>(p5)));\r
+}\r
+\r
 }
\ No newline at end of file