From 094a5ba83cbee5dc31c4df6004052749dad4d9e4 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 5 Nov 2018 09:23:03 +0100
Subject: [PATCH] update of cow_shared_ptr

---
 alib2std/src/extensions/memory.hpp | 63 ++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/alib2std/src/extensions/memory.hpp b/alib2std/src/extensions/memory.hpp
index 4d9e2a64c6..a7e9ee3140 100644
--- a/alib2std/src/extensions/memory.hpp
+++ b/alib2std/src/extensions/memory.hpp
@@ -69,6 +69,16 @@ public:
 	cow_shared_ptr ( const cow_shared_ptr & other ) : std::shared_ptr < T > ( other ) {
 	}
 
+	/**
+	 * \brief
+	 * Copy version of user conversion constructor to create new instance of shared pointer reffering the same data.
+	 *
+	 * \param other the source instance
+	 */
+	template < class Y >
+	cow_shared_ptr ( const cow_shared_ptr < Y > & other ) : std::shared_ptr < T > ( other ) {
+	}
+
 	/**
 	 * \brief
 	 * Move constructor to create new instance of shared pointer reffering the same data.
@@ -78,6 +88,16 @@ public:
 	cow_shared_ptr ( cow_shared_ptr && other ) noexcept : std::shared_ptr < T > ( std::move ( other ) ) {
 	}
 
+	/**
+	 * \brief
+	 * Move version of user conversion constructor to create new instance of shared pointer reffering the same data.
+	 *
+	 * \param other the source instance
+	 */
+	template < class Y >
+	cow_shared_ptr ( cow_shared_ptr < Y > && other ) noexcept : std::shared_ptr < T > ( std::move ( other ) ) {
+	}
+
 	/**
 	 * \brief
 	 * The destructor of the shared pointer.
@@ -96,6 +116,18 @@ public:
 		return * this;
 	}
 
+	/**
+	 * \brief
+	 * Copy version of user conversion assignment operator to change reffered instace to source one.
+	 *
+	 * \param other the source instance
+	 */
+	template < class Y >
+	cow_shared_ptr & operator =( const cow_shared_ptr < Y > & other ) {
+		static_cast < std::shared_ptr < T > & > ( * this ) = static_cast < const std::shared_ptr < T > & > ( other );
+		return * this;
+	}
+
 	/**
 	 * \brief
 	 * Move assignment operator to change reffered instace to source one.
@@ -107,6 +139,37 @@ public:
 		return * this;
 	}
 
+	/**
+	 * \brief
+	 * Move version of user conversion assignment operator to change reffered instace to source one.
+	 *
+	 * \param other the source instance
+	 */
+	template < class Y >
+	cow_shared_ptr & operator =( cow_shared_ptr < Y > && other ) noexcept {
+		static_cast < std::shared_ptr < T > & > ( * this ) = static_cast < std::shared_ptr < T > && > ( other );
+		return * this;
+	}
+
+	/**
+	 * \brief
+	 * Sets the shared pointer to nullptr.
+	 */
+	void reset ( ) noexcept {
+		return std::shared_ptr < T >::reset ( );
+	}
+
+	/**
+	 * \brief
+	 * Sets the shared pointer to value.
+	 *
+	 * \param ptr the value to store
+	 */
+	template < class Y >
+	void reset( Y * ptr ) {
+		return std::shared_ptr < T >::reset ( ptr );
+	}
+
 	/**
 	 * \brief
 	 * Operator arrow to chain dereferece to inner managed pointer.
-- 
GitLab