Skip to content
Snippets Groups Projects
Commit 094a5ba8 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

update of cow_shared_ptr

parent d71d12c9
No related branches found
No related tags found
No related merge requests found
...@@ -69,6 +69,16 @@ public: ...@@ -69,6 +69,16 @@ public:
cow_shared_ptr ( const cow_shared_ptr & other ) : std::shared_ptr < T > ( other ) { 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 * \brief
* Move constructor to create new instance of shared pointer reffering the same data. * Move constructor to create new instance of shared pointer reffering the same data.
...@@ -78,6 +88,16 @@ public: ...@@ -78,6 +88,16 @@ public:
cow_shared_ptr ( cow_shared_ptr && other ) noexcept : std::shared_ptr < T > ( std::move ( other ) ) { 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 * \brief
* The destructor of the shared pointer. * The destructor of the shared pointer.
...@@ -96,6 +116,18 @@ public: ...@@ -96,6 +116,18 @@ public:
return * this; 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 * \brief
* Move assignment operator to change reffered instace to source one. * Move assignment operator to change reffered instace to source one.
...@@ -107,6 +139,37 @@ public: ...@@ -107,6 +139,37 @@ public:
return * this; 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 * \brief
* Operator arrow to chain dereferece to inner managed pointer. * Operator arrow to chain dereferece to inner managed pointer.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment