template class auto_ptr { private: _Tp* _M_ptr; public: typedef _Tp element_type; explicit auto_ptr(_Tp* __p = 0) _THROW0() : _M_ptr(__p) {} template auto_ptr(auto_ptr<_Tp1>& __a) _THROW0() : _M_ptr(__a.release()) {} auto_ptr(auto_ptr& __a) _THROW0() : _M_ptr(__a.release()) {} template auto_ptr& operator=(auto_ptr<_Tp1>& __a) _THROW0() { if (__a.get() != this->get()) { delete _M_ptr; _M_ptr = __a.release(); } return *this; } auto_ptr& operator=(auto_ptr& __a) _THROW0() { if (&__a != this) { delete _M_ptr; _M_ptr = __a.release(); } return *this; } ~auto_ptr() _THROW0() { delete _M_ptr; } _Tp& operator*() const _THROW0() { return *_M_ptr; } _Tp* operator->() const _THROW0() { return _M_ptr; } _Tp* get() const _THROW0() { return _M_ptr; } _Tp* release() _THROW0() { _Tp* __tmp = _M_ptr; _M_ptr = 0; return __tmp; } void reset(_Tp* __p = 0) _THROW0() { delete _M_ptr; _M_ptr = __p; } // According to the C++ standard, these conversions are required. Most // present-day compilers, however, do not enforce that requirement---and, // in fact, most present-day compilers do not support the language // features that these conversions rely on. private: template struct auto_ptr_ref { _Tp1* _M_ptr; auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} }; public: auto_ptr(auto_ptr_ref<_Tp> __ref) _THROW0() : _M_ptr(__ref._M_ptr) {} template operator auto_ptr_ref<_Tp1>() _THROW0() { return auto_ptr_ref<_Tp>(this->release()); } template operator auto_ptr<_Tp1>() _THROW0() { return auto_ptr<_Tp1>(this->release()) } };