epoc32/include/stdapis/stlportv5/stl/_auto_ptr.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_auto_ptr.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_auto_ptr.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -1,5 +1,4 @@
     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 @@ -25,11 +24,12 @@
    1.10  class __ptr_base {
    1.11  public:
    1.12    void* _M_p;
    1.13 -  void  __set(const void* __p) { _M_p = __CONST_CAST(void*,__p); }
    1.14 -  void  __set(void* __p) { _M_p = __p; }
    1.15 +  void  __set(const void* pp) { _M_p = __CONST_CAST(void*,pp); }
    1.16 +  void  __set(void* pp) { _M_p = pp; }
    1.17  };
    1.18  
    1.19 -template <class _Tp> class auto_ptr_ref {
    1.20 +template <class _Tp>
    1.21 +class auto_ptr_ref {
    1.22  public:
    1.23    __ptr_base& _M_r;
    1.24    _Tp* const _M_p;
    1.25 @@ -38,133 +38,88 @@
    1.26  
    1.27    _Tp* release() const { _M_r.__set((void*)0); return _M_p; }
    1.28  
    1.29 +private:
    1.30 +  //explicitely defined as private to avoid warnings:
    1.31 +  typedef auto_ptr_ref<_Tp> _Self;
    1.32 +  _Self& operator = (_Self const&);
    1.33  };
    1.34  
    1.35 -template<class _Tp> class auto_ptr :  public __ptr_base {
    1.36 +template<class _Tp>
    1.37 +class auto_ptr :  public __ptr_base {
    1.38  public:
    1.39    typedef _Tp element_type;
    1.40 -  typedef auto_ptr<_Tp>           _Self;
    1.41 +  typedef auto_ptr<_Tp> _Self;
    1.42  
    1.43 -  _Tp* release() {
    1.44 +  _Tp* release() _STLP_NOTHROW {
    1.45      _Tp* __px = this->get();
    1.46      this->_M_p = 0;
    1.47      return __px;
    1.48    }
    1.49  
    1.50 -  void reset(_Tp* __px=0) {
    1.51 +  void reset(_Tp* __px = 0) _STLP_NOTHROW {
    1.52      _Tp* __pt = this->get();
    1.53      if (__px != __pt)
    1.54        delete __pt;
    1.55      this->__set(__px);
    1.56    }
    1.57  
    1.58 -  _Tp* get() const { return __REINTERPRET_CAST(_Tp*,__CONST_CAST(void*,_M_p)); }
    1.59 +  _Tp* get() const _STLP_NOTHROW
    1.60 +  { return __REINTERPRET_CAST(_Tp*,__CONST_CAST(void*,_M_p)); }
    1.61  
    1.62 -# if !defined (_STLP_NO_ARROW_OPERATOR)
    1.63 -  _Tp* operator->() const {
    1.64 +#if !defined (_STLP_NO_ARROW_OPERATOR)
    1.65 +  _Tp* operator->() const _STLP_NOTHROW {
    1.66      _STLP_VERBOSE_ASSERT(get()!=0, _StlMsg_AUTO_PTR_NULL)
    1.67      return get();
    1.68    }
    1.69 -# endif
    1.70 -  _Tp& operator*() const  {
    1.71 -    _STLP_VERBOSE_ASSERT(get()!=0, _StlMsg_AUTO_PTR_NULL)
    1.72 +#endif
    1.73 +  _Tp& operator*() const _STLP_NOTHROW {
    1.74 +    _STLP_VERBOSE_ASSERT(get()!= 0, _StlMsg_AUTO_PTR_NULL)
    1.75      return *get();
    1.76    }
    1.77  
    1.78 -  auto_ptr() {
    1.79 -    this->_M_p = 0;
    1.80 -# ifdef _STLP_USE_TRAP_LEAVE
    1.81 -    CleanupStack::PushL(TCleanupItem(Close, (void*)this));
    1.82 -# endif
    1.83 -  }
    1.84 -
    1.85 -  explicit auto_ptr(_Tp* __px) {
    1.86 -    this->__set(__px);
    1.87 -# ifdef _STLP_USE_TRAP_LEAVE
    1.88 -    CleanupStack::PushL(TCleanupItem(Close, (void*)this));
    1.89 -# endif
    1.90 -  }
    1.91 +  explicit auto_ptr(_Tp* __px = 0) _STLP_NOTHROW { this->__set(__px); }
    1.92  
    1.93  #if defined (_STLP_MEMBER_TEMPLATES)
    1.94 -# if !defined (_STLP_NO_TEMPLATE_CONVERSIONS)
    1.95 -  template<class _Tp1> auto_ptr(auto_ptr<_Tp1>& __r) {
    1.96 +#  if !defined (_STLP_NO_TEMPLATE_CONVERSIONS)
    1.97 +  template<class _Tp1> auto_ptr(auto_ptr<_Tp1>& __r) _STLP_NOTHROW {
    1.98      _Tp* __conversionCheck = __r.release();
    1.99      this->__set(__conversionCheck);
   1.100 -# ifdef _STLP_USE_TRAP_LEAVE
   1.101 -    CleanupStack::PushL(TCleanupItem(Close, (void*)this));
   1.102 -# endif
   1.103    }
   1.104 -# endif
   1.105 -  template<class _Tp1> auto_ptr<_Tp>& operator=(auto_ptr<_Tp1>& __r) {
   1.106 +#  endif
   1.107 +  template<class _Tp1> auto_ptr<_Tp>& operator=(auto_ptr<_Tp1>& __r) _STLP_NOTHROW {
   1.108      _Tp* __conversionCheck = __r.release();
   1.109      reset(__conversionCheck);
   1.110      return *this;
   1.111    }
   1.112 -#endif /* _STLP_MEMBER_TEMPLATES */
   1.113 +#endif
   1.114  
   1.115 -  auto_ptr(_Self& __r)
   1.116 -  { this->__set(__r.release());
   1.117 -# ifdef _STLP_USE_TRAP_LEAVE
   1.118 -    CleanupStack::PushL(TCleanupItem(Close, (void*)this));
   1.119 -# endif
   1.120 -  }
   1.121 +  auto_ptr(_Self& __r) _STLP_NOTHROW { this->__set(__r.release()); }
   1.122  
   1.123 -  _Self& operator=(_Self& __r)  {
   1.124 +  _Self& operator=(_Self& __r) _STLP_NOTHROW {
   1.125      reset(__r.release());
   1.126      return *this;
   1.127    }
   1.128  
   1.129 -  ~auto_ptr() { _STLP_POP_ITEM reset(0); }
   1.130 +  ~auto_ptr() _STLP_NOTHROW { /* boris : reset(0) might be better */ delete this->get(); }
   1.131  
   1.132 -  auto_ptr(auto_ptr_ref<_Tp> __r) {
   1.133 -    this->__set(__r.release());
   1.134 -# ifdef _STLP_USE_TRAP_LEAVE
   1.135 -    CleanupStack::PushL(TCleanupItem(Close, (void*)this));
   1.136 -# endif
   1.137 -  }
   1.138 +  auto_ptr(auto_ptr_ref<_Tp> __r) _STLP_NOTHROW
   1.139 +  { this->__set(__r.release()); }
   1.140  
   1.141 -  _Self& operator=(auto_ptr_ref<_Tp> __r) {
   1.142 +  _Self& operator=(auto_ptr_ref<_Tp> __r) _STLP_NOTHROW {
   1.143      reset(__r.release());
   1.144      return *this;
   1.145    }
   1.146  
   1.147 -
   1.148 -  _Self& operator=(_Tp* __px) {
   1.149 -  	reset(__px);
   1.150 -    return *this;
   1.151 -  }
   1.152 -
   1.153 -
   1.154 -
   1.155 -# if defined(_STLP_MEMBER_TEMPLATES) && !defined(_STLP_NO_TEMPLATE_CONVERSIONS)
   1.156 -  template<class _Tp1> operator auto_ptr_ref<_Tp1>() {
   1.157 -    return auto_ptr_ref<_Tp1>(*this, this->get());
   1.158 -  }
   1.159 -  template<class _Tp1> operator auto_ptr<_Tp1>() {
   1.160 -    return auto_ptr<_Tp1>(release());
   1.161 -  }
   1.162 -# else
   1.163 -  operator auto_ptr_ref<_Tp>()
   1.164 +#if defined(_STLP_MEMBER_TEMPLATES) && !defined(_STLP_NO_TEMPLATE_CONVERSIONS)
   1.165 +  template<class _Tp1> operator auto_ptr_ref<_Tp1>() _STLP_NOTHROW
   1.166 +  { return auto_ptr_ref<_Tp1>(*this, this->get()); }
   1.167 +  template<class _Tp1> operator auto_ptr<_Tp1>() _STLP_NOTHROW
   1.168 +  { return auto_ptr<_Tp1>(release()); }
   1.169 +#else
   1.170 +  operator auto_ptr_ref<_Tp>() _STLP_NOTHROW
   1.171    { return auto_ptr_ref<_Tp>(*this, this->get()); }
   1.172 -# endif
   1.173 -
   1.174 -# ifdef _STLP_USE_TRAP_LEAVE
   1.175 -  static void Close(void* aPtr);
   1.176 -# endif
   1.177 -
   1.178 +#endif
   1.179  };
   1.180 -
   1.181 -# ifdef _STLP_USE_TRAP_LEAVE
   1.182 -template <class _Tp>
   1.183 -void
   1.184 -auto_ptr<_Tp>::Close(void* aPtr)
   1.185 -{
   1.186 -  auto_ptr<_Tp>* self = (auto_ptr<_Tp>*)aPtr;
   1.187 -  self->reset(0);
   1.188 -}
   1.189 -# endif
   1.190 -
   1.191 -
   1.192  _STLP_END_NAMESPACE
   1.193  
   1.194  #endif /* _STLP_AUTO_PTR_H */
   1.195 @@ -172,4 +127,3 @@
   1.196  // Local Variables:
   1.197  // mode:C++
   1.198  // End:
   1.199 -