1 namespace std { 2 3 template <typename type> 4 class __shared_ptr { 5 protected: 6 __shared_ptr(); 7 __shared_ptr(type *ptr); 8 ~__shared_ptr(); 9 public: 10 type &operator*() { return *ptr; } 11 type *operator->() { return ptr; } 12 type *release(); 13 void reset(); 14 void reset(type *pt); 15 16 private: 17 type *ptr; 18 }; 19 20 template <typename type> 21 class shared_ptr : public __shared_ptr<type> { 22 public: 23 shared_ptr(); 24 shared_ptr(type *ptr); 25 shared_ptr(const shared_ptr<type> &t); 26 shared_ptr(shared_ptr<type> &&t); 27 ~shared_ptr(); 28 shared_ptr &operator=(shared_ptr &&); 29 template <typename T> 30 shared_ptr &operator=(shared_ptr<T> &&); 31 }; 32 33 } // namespace std 34