1.1 --- a/epoc32/include/stdapis/stlport/stl/_auto_ptr.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,175 +0,0 @@
1.4 -/*
1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.6 - * Copyright (c) 1997-1999
1.7 - * Silicon Graphics Computer Systems, Inc.
1.8 - *
1.9 - * Copyright (c) 1999
1.10 - * Boris Fomitchev
1.11 - *
1.12 - * This material is provided "as is", with absolutely no warranty expressed
1.13 - * or implied. Any use is at your own risk.
1.14 - *
1.15 - * Permission to use or copy this software for any purpose is hereby granted
1.16 - * without fee, provided the above notices are retained on all copies.
1.17 - * Permission to modify the code and to distribute modified code is granted,
1.18 - * provided the above notices are retained, and a notice that the code was
1.19 - * modified is included with the above copyright notice.
1.20 - *
1.21 - */
1.22 -
1.23 -#ifndef _STLP_AUTO_PTR_H
1.24 -# define _STLP_AUTO_PTR_H
1.25 -
1.26 -_STLP_BEGIN_NAMESPACE
1.27 -// implementation primitive
1.28 -class __ptr_base {
1.29 -public:
1.30 - void* _M_p;
1.31 - void __set(const void* __p) { _M_p = __CONST_CAST(void*,__p); }
1.32 - void __set(void* __p) { _M_p = __p; }
1.33 -};
1.34 -
1.35 -template <class _Tp> class auto_ptr_ref {
1.36 -public:
1.37 - __ptr_base& _M_r;
1.38 - _Tp* const _M_p;
1.39 -
1.40 - auto_ptr_ref(__ptr_base& __r, _Tp* __p) : _M_r(__r), _M_p(__p) { }
1.41 -
1.42 - _Tp* release() const { _M_r.__set((void*)0); return _M_p; }
1.43 -
1.44 -};
1.45 -
1.46 -template<class _Tp> class auto_ptr : public __ptr_base {
1.47 -public:
1.48 - typedef _Tp element_type;
1.49 - typedef auto_ptr<_Tp> _Self;
1.50 -
1.51 - _Tp* release() {
1.52 - _Tp* __px = this->get();
1.53 - this->_M_p = 0;
1.54 - return __px;
1.55 - }
1.56 -
1.57 - void reset(_Tp* __px=0) {
1.58 - _Tp* __pt = this->get();
1.59 - if (__px != __pt)
1.60 - delete __pt;
1.61 - this->__set(__px);
1.62 - }
1.63 -
1.64 - _Tp* get() const { return __REINTERPRET_CAST(_Tp*,__CONST_CAST(void*,_M_p)); }
1.65 -
1.66 -# if !defined (_STLP_NO_ARROW_OPERATOR)
1.67 - _Tp* operator->() const {
1.68 - _STLP_VERBOSE_ASSERT(get()!=0, _StlMsg_AUTO_PTR_NULL)
1.69 - return get();
1.70 - }
1.71 -# endif
1.72 - _Tp& operator*() const {
1.73 - _STLP_VERBOSE_ASSERT(get()!=0, _StlMsg_AUTO_PTR_NULL)
1.74 - return *get();
1.75 - }
1.76 -
1.77 - auto_ptr() {
1.78 - this->_M_p = 0;
1.79 -# ifdef _STLP_USE_TRAP_LEAVE
1.80 - CleanupStack::PushL(TCleanupItem(Close, (void*)this));
1.81 -# endif
1.82 - }
1.83 -
1.84 - explicit auto_ptr(_Tp* __px) {
1.85 - this->__set(__px);
1.86 -# ifdef _STLP_USE_TRAP_LEAVE
1.87 - CleanupStack::PushL(TCleanupItem(Close, (void*)this));
1.88 -# endif
1.89 - }
1.90 -
1.91 -#if defined (_STLP_MEMBER_TEMPLATES)
1.92 -# if !defined (_STLP_NO_TEMPLATE_CONVERSIONS)
1.93 - template<class _Tp1> auto_ptr(auto_ptr<_Tp1>& __r) {
1.94 - _Tp* __conversionCheck = __r.release();
1.95 - this->__set(__conversionCheck);
1.96 -# ifdef _STLP_USE_TRAP_LEAVE
1.97 - CleanupStack::PushL(TCleanupItem(Close, (void*)this));
1.98 -# endif
1.99 - }
1.100 -# endif
1.101 - template<class _Tp1> auto_ptr<_Tp>& operator=(auto_ptr<_Tp1>& __r) {
1.102 - _Tp* __conversionCheck = __r.release();
1.103 - reset(__conversionCheck);
1.104 - return *this;
1.105 - }
1.106 -#endif /* _STLP_MEMBER_TEMPLATES */
1.107 -
1.108 - auto_ptr(_Self& __r)
1.109 - { this->__set(__r.release());
1.110 -# ifdef _STLP_USE_TRAP_LEAVE
1.111 - CleanupStack::PushL(TCleanupItem(Close, (void*)this));
1.112 -# endif
1.113 - }
1.114 -
1.115 - _Self& operator=(_Self& __r) {
1.116 - reset(__r.release());
1.117 - return *this;
1.118 - }
1.119 -
1.120 - ~auto_ptr() { _STLP_POP_ITEM reset(0); }
1.121 -
1.122 - auto_ptr(auto_ptr_ref<_Tp> __r) {
1.123 - this->__set(__r.release());
1.124 -# ifdef _STLP_USE_TRAP_LEAVE
1.125 - CleanupStack::PushL(TCleanupItem(Close, (void*)this));
1.126 -# endif
1.127 - }
1.128 -
1.129 - _Self& operator=(auto_ptr_ref<_Tp> __r) {
1.130 - reset(__r.release());
1.131 - return *this;
1.132 - }
1.133 -
1.134 -
1.135 - _Self& operator=(_Tp* __px) {
1.136 - reset(__px);
1.137 - return *this;
1.138 - }
1.139 -
1.140 -
1.141 -
1.142 -# if defined(_STLP_MEMBER_TEMPLATES) && !defined(_STLP_NO_TEMPLATE_CONVERSIONS)
1.143 - template<class _Tp1> operator auto_ptr_ref<_Tp1>() {
1.144 - return auto_ptr_ref<_Tp1>(*this, this->get());
1.145 - }
1.146 - template<class _Tp1> operator auto_ptr<_Tp1>() {
1.147 - return auto_ptr<_Tp1>(release());
1.148 - }
1.149 -# else
1.150 - operator auto_ptr_ref<_Tp>()
1.151 - { return auto_ptr_ref<_Tp>(*this, this->get()); }
1.152 -# endif
1.153 -
1.154 -# ifdef _STLP_USE_TRAP_LEAVE
1.155 - static void Close(void* aPtr);
1.156 -# endif
1.157 -
1.158 -};
1.159 -
1.160 -# ifdef _STLP_USE_TRAP_LEAVE
1.161 -template <class _Tp>
1.162 -void
1.163 -auto_ptr<_Tp>::Close(void* aPtr)
1.164 -{
1.165 - auto_ptr<_Tp>* self = (auto_ptr<_Tp>*)aPtr;
1.166 - self->reset(0);
1.167 -}
1.168 -# endif
1.169 -
1.170 -
1.171 -_STLP_END_NAMESPACE
1.172 -
1.173 -#endif /* _STLP_AUTO_PTR_H */
1.174 -
1.175 -// Local Variables:
1.176 -// mode:C++
1.177 -// End:
1.178 -