#include <Value_Ptr.h>
Collaboration diagram for ACE::Value_Ptr< T >:
Public Member Functions | |
Value_Ptr (T *p=0) | |
Constructor. | |
~Value_Ptr (void) | |
Destructor. | |
T & | operator * (void) const |
Deference operator. | |
T * | operator-> (void) const |
Pointer operator. | |
void | swap (Value_Ptr &other) |
Value_Ptr (Value_Ptr const &other) | |
Copy constructor. | |
Value_Ptr & | operator= (Value_Ptr const &other) |
Assignment operator. | |
template<typename U> | |
Value_Ptr (Value_Ptr< U > const &other) | |
Converting copy constructor. | |
template<typename U> | |
Value_Ptr & | operator= (Value_Ptr< U > const &other) |
Converting assignment operator. | |
Private Member Functions | |
template<typename U> | |
T * | create_from (U const *p) const |
Copying method invoked when copy constructing. | |
Private Attributes | |
T * | p_ |
Object owned by this Value_Ptr . | |
Friends | |
class | Value_Ptr |
Using a std::auto_ptr<>
as a class member is sometimes problematic since ownership of memory is transferred when copying such members. This Value_Ptr
class is explicitly designed to avoid such problems by performing copies of the underlying object rather than transfer ownership. This, for example, allows it to be readily used as a member in classes placed inside STL containers.
Definition at line 67 of file Value_Ptr.h.
ACE::Value_Ptr< T >::Value_Ptr | ( | T * | p = 0 |
) | [inline, explicit] |
ACE::Value_Ptr< T >::~Value_Ptr | ( | void | ) | [inline] |
Destructor.
Definition at line 75 of file Value_Ptr.h.
References ACE::Value_Ptr< T >::p_.
00075 { delete this->p_; }
ACE::Value_Ptr< T >::Value_Ptr | ( | Value_Ptr< T > const & | other | ) | [inline] |
ACE::Value_Ptr< T >::Value_Ptr | ( | Value_Ptr< U > const & | other | ) | [inline] |
Converting copy constructor.
Definition at line 113 of file Value_Ptr.h.
00114 : p_ (create_from (other.p_)) { }
T* ACE::Value_Ptr< T >::create_from | ( | U const * | p | ) | const [inline, private] |
T& ACE::Value_Ptr< T >::operator * | ( | void | ) | const [inline] |
Deference operator.
Definition at line 78 of file Value_Ptr.h.
References ACE::Value_Ptr< T >::p_.
00078 { return *this->p_; }
T* ACE::Value_Ptr< T >::operator-> | ( | void | ) | const [inline] |
Pointer operator.
Definition at line 81 of file Value_Ptr.h.
References ACE::Value_Ptr< T >::p_.
00081 { return this->p_; }
Value_Ptr& ACE::Value_Ptr< T >::operator= | ( | Value_Ptr< U > const & | other | ) | [inline] |
Converting assignment operator.
Definition at line 118 of file Value_Ptr.h.
References ACE::Value_Ptr< T >::swap().
00119 { 00120 // Strongly exception-safe. 00121 Value_Ptr temp (other); 00122 this->swap (temp); 00123 return *this; 00124 }
Value_Ptr& ACE::Value_Ptr< T >::operator= | ( | Value_Ptr< T > const & | other | ) | [inline] |
Assignment operator.
Definition at line 98 of file Value_Ptr.h.
References ACE::Value_Ptr< T >::swap().
00099 { 00100 // Strongly exception-safe. 00101 Value_Ptr temp (other); 00102 this->swap (temp); 00103 return *this; 00104 }
void ACE::Value_Ptr< T >::swap | ( | Value_Ptr< T > & | other | ) | [inline] |
auto_ptr<>s
, but why would one use an auto_ptr<>
as the template argument for this particular template class!? Definition at line 91 of file Value_Ptr.h.
References ACE::Value_Ptr< T >::p_.
Referenced by ACE::Value_Ptr< T >::operator=().
friend class Value_Ptr [friend] |
Definition at line 155 of file Value_Ptr.h.
T* ACE::Value_Ptr< T >::p_ [private] |
Object owned by this Value_Ptr
.
Definition at line 159 of file Value_Ptr.h.
Referenced by ACE::Value_Ptr< T >::operator *(), ACE::Value_Ptr< T >::operator->(), ACE::Value_Ptr< T >::swap(), and ACE::Value_Ptr< T >::~Value_Ptr().