14 typedef T element_type;
22 RefPtr(
const RefPtr<T>& ptr)
32 explicitDecRef(m_ptr);
38 RefPtr<T>& operator=(U* ptr)
44 explicitDecRef(m_ptr);
49 explicitIncRef(m_ptr);
56 RefPtr<T>& operator=(
const RefPtr<U>& ptr)
77 assert(
get() &&
"Accessing member of null pointer!");
83 assert(
get() &&
"Dereferencing null pointer!");
87 typedef RefPtr<T> this_type;
95 return (
get() ? &this_type::m_ptr : 0);
100 assert(!m_ptr || m_ptr->getRefCount() > 0 &&
101 "Dereferencing pointer with refCount <= 0");
112 T* get_pointer(
const RefPtr<T>& p)
118 template<
typename T,
typename U>
119 bool operator==(
const RefPtr<T>& a,
const RefPtr<U>& b)
121 return (a.get() == b.get());
124 template<
typename T,
typename U>
125 bool operator==(
const RefPtr<T>& a,
const U* b)
127 return (a.get() == b);
130 template<
typename T,
typename U>
131 bool operator==(
const T* a,
const RefPtr<U>& b)
133 return (a == b.get());
137 template<
typename T,
typename U>
138 bool operator!=(
const RefPtr<T>& a,
const RefPtr<U>& b)
140 return (a.get() != b.get());
143 template<
typename T,
typename U>
144 bool operator!=(
const RefPtr<T>& a,
const U* b)
146 return (a.get() != b);
149 template<
typename T,
typename U>
150 bool operator!=(
const T* a,
const RefPtr<U>& b)
152 return (a != b.get());
156 template<
typename T,
typename U>
157 bool operator<(const RefPtr<T>& a,
const RefPtr<U>& b)
159 return (a.get() < b.get());
162 template<
typename T,
typename U>
163 bool operator<(const RefPtr<T>& a,
const U* b)
165 return (a.get() < b);
168 template<
typename T,
typename U>
169 bool operator<(const T* a, const RefPtr<U>& b)
171 return (a < b.get());
RefPtr< T > & operator=(const RefPtr< T > &ptr)
Need this to override the built-in operator=.
Definition: refptr.h:63
A container-safe smart pointer used for refcounted classes.
Definition: refcounted.h:11
bool operator!() const
Need this to override the built-in operator!
Definition: refptr.h:70
T *this_type::* unspecified_bool_type
Inspired by boost's smart_ptr facilities.
Definition: refptr.h:90