diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-11-02 11:03:27 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-11-02 11:03:27 +0000 |
commit | 688ba8920d2a0804caa8b8321c97d6f85e950dd3 (patch) | |
tree | 7b729be96bfa676f133f562057cf68f0b4b9ca5e /TAO/tao/VarOut_T.cpp | |
parent | 44898ad83aa0c59bcfba8f0299d76362f1c6a68b (diff) | |
download | ATCD-688ba8920d2a0804caa8b8321c97d6f85e950dd3.tar.gz |
ChangeLogTag:Tue Nov 1 14:49:40 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/tao/VarOut_T.cpp')
-rw-r--r-- | TAO/tao/VarOut_T.cpp | 94 |
1 files changed, 26 insertions, 68 deletions
diff --git a/TAO/tao/VarOut_T.cpp b/TAO/tao/VarOut_T.cpp index 618198edfad..b53bedc3a62 100644 --- a/TAO/tao/VarOut_T.cpp +++ b/TAO/tao/VarOut_T.cpp @@ -1,7 +1,7 @@ // $Id$ -#ifndef TAO_VAROUT_T_C -#define TAO_VAROUT_T_C +#ifndef TAO_VAROUT_T_CPP +#define TAO_VAROUT_T_CPP #include "tao/VarOut_T.h" @@ -9,22 +9,12 @@ #include "tao/VarOut_T.inl" #endif /* __ACE_INLINE__ */ -ACE_RCSID (tao, - VarOut_T, - "$Id$") +TAO_BEGIN_VERSIONED_NAMESPACE_DECL template<typename T> TAO_Var_Base_T<T>::TAO_Var_Base_T (const TAO_Var_Base_T<T> & p) + : ptr_ (p.ptr_ ? new T (*p.ptr_) : 0) { - if (p.ptr_) - { - ACE_NEW (this->ptr_, - T (*p.ptr_)); - } - else - { - this->ptr_ = 0; - } } // ************************************************************* @@ -33,29 +23,13 @@ template<typename T> TAO_Fixed_Var_T<T> & TAO_Fixed_Var_T<T>::operator= (const TAO_Fixed_Var_T<T> & p) { - if (this != &p) - { - if (p.ptr_ == 0) - { - delete this->ptr_; - this->ptr_ = 0; - } - else - { - T * deep_copy = 0; - ACE_NEW_RETURN (deep_copy, - T (*p.ptr_), - *this); - - if (deep_copy != 0) - { - T * tmp = deep_copy; - deep_copy = this->ptr_; - this->ptr_ = tmp; - delete deep_copy; - } - } - } + // Strongly exception safe assignment using copy and non-throwing + // swap technique. + TAO_Fixed_Var_T<T> tmp (p); + + T * old_ptr = this->ptr_; + this->ptr_ = tmp.ptr_; + tmp.ptr_ = old_ptr; return *this; } @@ -65,13 +39,13 @@ template<typename T> TAO_Fixed_Var_T<T> & TAO_Fixed_Var_T<T>::operator= (const T & p) { - if (this->ptr_ != &p) - { - delete this->ptr_; - ACE_NEW_RETURN (this->ptr_, - T (p), - *this); - } + // Strongly exception safe assignment using copy and non-throwing + // swap technique. + TAO_Fixed_Var_T<T> tmp (p); + + T * old_ptr = this->ptr_; + this->ptr_ = tmp.ptr_; + tmp.ptr_ = old_ptr; return *this; } @@ -82,31 +56,15 @@ template<typename T> TAO_Var_Var_T<T> & TAO_Var_Var_T<T>::operator= (const TAO_Var_Var_T<T> & p) { - if (this != &p) - { - if (p.ptr_ == 0) - { - delete this->ptr_; - this->ptr_ = 0; - } - else - { - T *deep_copy = 0; - ACE_NEW_RETURN (deep_copy, - T (*p.ptr_), - *this); - - if (deep_copy != 0) - { - T * tmp = deep_copy; - deep_copy = this->ptr_; - this->ptr_ = tmp; - delete deep_copy; - } - } - } + // Strongly exception safe assignment using copy and non-throwing + // swap technique. + TAO_Var_Var_T<T> tmp (p); + + T * old_ptr = this->ptr_; + this->ptr_ = tmp.ptr_; + tmp.ptr_ = old_ptr; return *this; } -#endif /* TAO_VAROUT_T_C */ +#endif /* TAO_VAROUT_T_CPP */ |