46 lines · c
1#ifndef INPUTS_MEMORY_H2#define INPUTS_MEMORY_H3 4namespace std {5 6inline namespace _1 {7 8template <class Y> struct auto_ptr_ref {9 Y *y_;10};11 12template <class X> class auto_ptr {13public:14 typedef X element_type;15 explicit auto_ptr(X *p = 0) throw() {}16 auto_ptr(auto_ptr &) throw() {}17 template <class Y> auto_ptr(auto_ptr<Y> &) throw() {}18 auto_ptr &operator=(auto_ptr &) throw() { return *this; }19 template <class Y> auto_ptr &operator=(auto_ptr<Y> &) throw() {20 return *this;21 }22 auto_ptr &operator=(auto_ptr_ref<X> r) throw() { return *this; }23 ~auto_ptr() throw() {}24 auto_ptr(auto_ptr_ref<X> r) throw() : x_(r.y_) {}25 template <class Y> operator auto_ptr_ref<Y>() throw() {26 auto_ptr_ref<Y> r;27 r.y_ = x_;28 return r;29 }30 template <class Y> operator auto_ptr<Y>() throw() { return auto_ptr<Y>(x_); }31 32private:33 X *x_;34};35 36template <> class auto_ptr<void> {37public:38 typedef void element_type;39};40 41} // namespace _142 43} // end namespace std44 45#endif // INPUTS_MEMORY_H46