onilink_

Untitled

Feb 11th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. template <typename T>
  2. struct deep_ptr:
  3.     public std::unique_ptr<T>
  4. {
  5.     using std::unique_ptr<T>::unique_ptr;
  6.    
  7.     deep_ptr() {}
  8.     deep_ptr(deep_ptr<T> const& other)
  9.     {
  10.         this->reset(new T(*other.get()));
  11.     }
  12.     deep_ptr(std::unique_ptr<T> other):
  13.         std::unique_ptr<T>( std::move(other) )
  14.     {
  15.     }
  16.     deep_ptr<T>& operator=(deep_ptr<T> const& other)
  17.     {
  18.         this->reset(new T(*other.get()));
  19.         return *this;
  20.     }
  21. };
Advertisement
Add Comment
Please, Sign In to add comment