2 #ifndef _REFCOUNTER_CPP_ 3 #define _REFCOUNTER_CPP_ 103 template <
typename T>
112 template <
typename T>
120 template <
typename T>
128 template <
typename T>
137 template <
typename T>
152 template <
typename T>
154 : t_ (t), refcount_ (1)
158 template <
typename T>
T & operator*(void)
dereference operator
T * operator->(void)
mimic pointer dereferencing
A shim class that keeps track of the reference count and a pointer to the type T that's reference cou...
Shim * ptr_
Pointer to the Shim.
T * t_
Pointer to the object that's being reference counted.
T * get_ptr(void)
get the underlying pointer
virtual ~Refcounter(void)
Dtor will delete pointer if refcount becomes 0.
T * get(void)
get the underlying pointer
void decrement(void)
implementation of the decrement operation
void increment(void)
implementation of the increment operation
This template class provides transparent reference counting of its template parameter T...
Refcounter(void)
default Ctor
int refcount_
Current value of the reference count.
void operator=(T *ptr)
assignment operator for times when you don't want the reference increased for incoming ptr ...