[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Intrusive_Auto_Ptr.inl
blob4feb83db7b1a8aa3f32181df73cba10dac4371c9
1 // -*- C++ -*-
2 //
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)
12   : rep_ (p)
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)
20   : rep_ (r.rep_)
22   if (rep_ != 0)
23     X::intrusive_add_ref (rep_);
26 template <class X> ACE_INLINE X *
27 ACE_Intrusive_Auto_Ptr<X>::operator-> (void) const
29     return this->rep_;
32 template<class X> ACE_INLINE X &
33 ACE_Intrusive_Auto_Ptr<X>::operator *() const
35   return *this->rep_;
38 template <class X> ACE_INLINE X*
39 ACE_Intrusive_Auto_Ptr<X>::get (void) const
41   // We return the ACE_Future_rep.
42   return this->rep_;
45 template<class X> ACE_INLINE X *
46 ACE_Intrusive_Auto_Ptr<X>::release (void)
48   X *p = this->rep_;
49   if (this->rep_ != 0)
50     X::intrusive_remove_ref (this->rep_);
52   this->rep_ = 0;
53   return p;
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
60   // pointer value.
61   if (this->rep_ == p)
62     return;
64   X *old_rep = this->rep_;
65   this->rep_ = p;
67   if (this->rep_ != 0)
68     X::intrusive_add_ref (this->rep_);
70   if (old_rep != 0)
71     X::intrusive_remove_ref (old_rep);
73   return;
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_)
81     return;
83   // assign a zero
84   if (rhs.rep_  == 0)
85     {
86       X::intrusive_remove_ref (rhs.rep_);
87       this->rep_ = 0;
88       return;
89     }
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.
111   /**
112    * @note It also returns @c true if both objects have just been
113    *       instantiated and not used yet.
114    */
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)
128     return a.get() == b;
131       template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b)
133     return a.get() != b;
136         template<class T, class U> ACE_INLINE bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
138     return a == b.get();
141           template<class T, class U> ACE_INLINE bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
143     return a != b.get();
147 ACE_END_VERSIONED_NAMESPACE_DECL