2 #include "ace/Guard_T.h"
3 #include "ace/Log_Category.h"
5 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
7 template <class X> ACE_INLINE
8 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (X *p, bool addref)
11 if (rep_ != 0 && addref)
12 X::intrusive_add_ref (rep_);
15 template <class X> ACE_INLINE
16 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<X> &r)
20 X::intrusive_add_ref (rep_);
23 template <class X> ACE_INLINE X *
24 ACE_Intrusive_Auto_Ptr<X>::operator-> () const
29 template<class X> ACE_INLINE X &
30 ACE_Intrusive_Auto_Ptr<X>::operator *() const
35 template <class X> ACE_INLINE X*
36 ACE_Intrusive_Auto_Ptr<X>::get () const
38 // We return the ACE_Future_rep.
42 template<class X> ACE_INLINE X *
43 ACE_Intrusive_Auto_Ptr<X>::release ()
47 X::intrusive_remove_ref (this->rep_);
53 template<class X> ACE_INLINE void
54 ACE_Intrusive_Auto_Ptr<X>::reset (X *p)
56 // Avoid deleting the underlying auto_ptr if assigning the same actual
61 X *old_rep = this->rep_;
65 X::intrusive_add_ref (this->rep_);
68 X::intrusive_remove_ref (old_rep);
73 template <class X> ACE_INLINE void
74 ACE_Intrusive_Auto_Ptr<X>::operator = (const ACE_Intrusive_Auto_Ptr<X> &rhs)
76 // do nothing when aliasing
77 if (this->rep_ == rhs.rep_)
83 X::intrusive_remove_ref (this->rep_);
88 // bind <this> to the same <ACE_Intrusive_Auto_Ptr_Rep> as <rhs>.
89 X *old_rep = this->rep_;
90 this->rep_ = rhs.rep_;
91 X::intrusive_add_ref (this->rep_);
92 X::intrusive_remove_ref (old_rep);
95 // Copy derived class constructor
96 template<class X> template <class U> ACE_INLINE
97 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<U> & rhs)
99 // note implicit cast from U* to T* so illegal copy will generate a
100 // compiler warning here
101 this->rep_ = rhs.operator-> ();
102 X::intrusive_add_ref(this->rep_);
105 /// Equality operator that returns @c true if both
106 /// ACE_Intrusive_Auto_Ptr objects point to the same underlying
107 /// representation. It does not compare the actual pointers.
109 * @note It also returns @c true if both objects have just been
110 * instantiated and not used yet.
112 template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b)
114 return a.get() == b.get();
117 /// Inequality operator, which is the opposite of equality.
118 template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b)
120 return a.get() != b.get();
123 template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, U * b)
128 template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b)
133 template<class T, class U> ACE_INLINE bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
138 template<class T, class U> ACE_INLINE bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
143 ACE_END_VERSIONED_NAMESPACE_DECL