3 * Silicon Graphics Computer Systems, Inc.
5 * Permission to use, copy, modify, distribute and sell this software
6 * and its documentation for any purpose is hereby granted without fee,
7 * provided that the above copyright notice appear in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation. Silicon Graphics makes no
10 * representations about the suitability of this software for any
11 * purpose. It is provided "as is" without express or implied warranty.
15 #ifndef __SGI_STL_MEMORY
16 #define __SGI_STL_MEMORY
18 #include <stl_algobase.h>
19 #include <stl_alloc.h>
20 #include <stl_construct.h>
21 #include <stl_tempbuf.h>
22 #include <stl_uninitialized.h>
23 #include <stl_raw_storage_iter.h>
26 #if defined(__STL_MEMBER_TEMPLATES)
30 template <class _Tp> class auto_ptr {
35 typedef _Tp element_type;
36 explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {}
37 auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {}
38 template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW
39 : _M_ptr(__a.release()) {}
40 auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW {
43 _M_ptr = __a.release();
48 auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW {
49 if (__a.get() != this->get()) {
51 _M_ptr = __a.release();
55 ~auto_ptr() __STL_NOTHROW { delete _M_ptr; }
57 _Tp& operator*() const __STL_NOTHROW {
60 _Tp* operator->() const __STL_NOTHROW {
63 _Tp* get() const __STL_NOTHROW {
66 _Tp* release() __STL_NOTHROW {
71 void reset(_Tp* __p = 0) __STL_NOTHROW {
76 // According to the C++ standard, these conversions are required. Most
77 // present-day compilers, however, do not enforce that requirement---and,
78 // in fact, most present-day compilers do not support the language
79 // features that these conversions rely on.
81 #ifdef __SGI_STL_USE_AUTO_PTR_CONVERSIONS
84 template<class _Tp1> struct auto_ptr_ref {
86 auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {}
90 auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW
91 : _M_ptr(__ref._M_ptr) {}
92 template <class _Tp1> operator auto_ptr_ref<_Tp1>() __STL_NOTHROW
93 { return auto_ptr_ref<_Tp>(this.release()); }
94 template <class _Tp1> operator auto_ptr<_Tp1>() __STL_NOTHROW
95 { return auto_ptr<_Tp1>(this->release()) }
97 #endif /* __SGI_STL_USE_AUTO_PTR_CONVERSIONS */
101 #endif /* member templates */
103 #endif /* __SGI_STL_MEMORY */