3 // $Id: Intrusive_Auto_Ptr.inl 81219 2008-04-02 20:23:32Z iliyan $
5 #include "ace/Guard_T.h"
6 #include "ace/Log_Msg.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 template <class X> ACE_INLINE
11 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (X *p, bool addref)
14 if (rep_ != 0 && addref)
15 X::intrusive_add_ref (rep_);
18 template <class X> ACE_INLINE
19 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<X> &r)
23 X::intrusive_add_ref (rep_);
26 template <class X> ACE_INLINE X *
27 ACE_Intrusive_Auto_Ptr<X>::operator-> (void) const
32 template<class X> ACE_INLINE X &
33 ACE_Intrusive_Auto_Ptr<X>::operator *() const
38 template <class X> ACE_INLINE X*
39 ACE_Intrusive_Auto_Ptr<X>::get (void) const
41 // We return the ACE_Future_rep.
45 template<class X> ACE_INLINE X *
46 ACE_Intrusive_Auto_Ptr<X>::release (void)
50 X::intrusive_remove_ref (this->rep_);
56 template<class X> ACE_INLINE void
57 ACE_Intrusive_Auto_Ptr<X>::reset (X *p)
59 // Avoid deleting the underlying auto_ptr if assigning the same actual
64 X *old_rep = this->rep_;
68 X::intrusive_add_ref (this->rep_);
71 X::intrusive_remove_ref (old_rep);
76 template <class X> ACE_INLINE void
77 ACE_Intrusive_Auto_Ptr<X>::operator = (const ACE_Intrusive_Auto_Ptr<X> &rhs)
79 // do nothing when aliasing
80 if (this->rep_ == rhs.rep_)
86 X::intrusive_remove_ref (rhs.rep_);
91 // bind <this> to the same <ACE_Intrusive_Auto_Ptr_Rep> as <rhs>.
92 X *old_rep = this->rep_;
93 this->rep_ = rhs.rep_;
94 X::intrusive_add_ref (this->rep_);
95 X::intrusive_remove_ref (old_rep);
98 // Copy derived class constructor
99 template<class X> template <class U> ACE_INLINE
100 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<U> & rhs)
102 // note implicit cast from U* to T* so illegal copy will generate a
103 // compiler warning here
104 this->rep_ = rhs.operator-> ();
105 X::intrusive_add_ref(this->rep_);
108 /// Equality operator that returns @c true if both
109 /// ACE_Intrusive_Auto_Ptr objects point to the same underlying
110 /// representation. It does not compare the actual pointers.
112 * @note It also returns @c true if both objects have just been
113 * instantiated and not used yet.
115 template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b)
117 return a.get() == b.get();
120 /// Inequality operator, which is the opposite of equality.
121 template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b)
123 return a.get() != b.get();
126 template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, U * b)
131 template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b)
136 template<class T, class U> ACE_INLINE bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
141 template<class T, class U> ACE_INLINE bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
147 ACE_END_VERSIONED_NAMESPACE_DECL