|
@ -62,11 +62,7 @@ public: |
|
|
template<class... Args> |
|
|
template<class... Args> |
|
|
Wrapper(Args... args) : value{ this->_new(args...) } {} |
|
|
Wrapper(Args... args) : value{ this->_new(args...) } {} |
|
|
|
|
|
|
|
|
// no implicit copying... (yet?)
|
|
|
// move is easy, efficient and generic:
|
|
|
Wrapper(const Wrapper<T*>&) = delete; |
|
|
|
|
|
void operator=(const Wrapper<T*>&) = delete; |
|
|
|
|
|
|
|
|
|
|
|
// must be implemented separately for each T
|
|
|
|
|
|
Wrapper(Wrapper<T*>&& victim) |
|
|
Wrapper(Wrapper<T*>&& victim) |
|
|
: value{ victim.value} |
|
|
: value{ victim.value} |
|
|
{ |
|
|
{ |
|
@ -80,6 +76,18 @@ public: |
|
|
victim.value = nullptr; |
|
|
victim.value = nullptr; |
|
|
return *this; |
|
|
return *this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Wrapper(const Wrapper<T*>& orig) |
|
|
|
|
|
: value{ orig.copy_out() } |
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
Wrapper<T*>& operator=(const Wrapper<T*>& orig) |
|
|
|
|
|
{ |
|
|
|
|
|
if(&orig == this) return *this; |
|
|
|
|
|
_free(value); |
|
|
|
|
|
value = orig.copy_out(); |
|
|
|
|
|
return *this; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
~Wrapper() |
|
|
~Wrapper() |
|
|
{ |
|
|
{ |
|
@ -107,7 +115,7 @@ public: |
|
|
|
|
|
|
|
|
// only implemented for the datatypes where necessay.
|
|
|
// only implemented for the datatypes where necessay.
|
|
|
// other implementations can follow if necessary.
|
|
|
// other implementations can follow if necessary.
|
|
|
T* copy_out(); |
|
|
T* copy_out() const; |
|
|
|
|
|
|
|
|
protected: |
|
|
protected: |
|
|
|
|
|
|
|
|