diff options
Diffstat (limited to 'ace/Auto_Ptr.h')
-rw-r--r-- | ace/Auto_Ptr.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ace/Auto_Ptr.h b/ace/Auto_Ptr.h index 1f0d93062dc..5fe2908937f 100644 --- a/ace/Auto_Ptr.h +++ b/ace/Auto_Ptr.h @@ -32,6 +32,9 @@ # pragma warning(disable: 4284) #endif /* _MSC_VER */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + /** * @class ACE_Auto_Basic_Ptr * @@ -65,6 +68,8 @@ protected: X *p_; }; +ACE_END_VERSIONED_NAMESPACE_DECL + #if !defined (ACE_LACKS_AUTO_PTR) && \ defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \ (ACE_HAS_STANDARD_CPP_LIBRARY != 0) @@ -93,6 +98,7 @@ public: #endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ +ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** * @brief Implements the draft C++ standard auto_ptr abstraction. @@ -163,17 +169,24 @@ public: X *operator-> () const; }; +ACE_END_VERSIONED_NAMESPACE_DECL + // Some platforms have an older version of auto_ptr // support, which lacks reset, and cannot be disabled // easily. Portability to these platforms requires // use of the following ACE_AUTO_PTR_RESET macro. +// +// Note that this macro correctly handles the case where NEWPTR may be +// a call to operator new(), e.g. "new foo", by making sure it is only +// evaluated once. # if defined (ACE_AUTO_PTR_LACKS_RESET) # define ACE_AUTO_PTR_RESET(AUTOPTR,NEWPTR,TYPE) \ do { \ - if (NEWPTR != AUTOPTR.get ()) \ + TYPE * tmp_ptr = NEWPTR; \ + if (tmp_ptr != AUTOPTR.get ()) \ { \ - AUTOPTR.release (); \ - AUTOPTR = auto_ptr<TYPE> (NEWPTR); \ + delete AUTOPTR.release (); \ + AUTOPTR = auto_ptr<TYPE> (tmp_ptr); \ } \ } while (0) # else /* ! ACE_AUTO_PTR_LACKS_RESET */ |