28 #if !defined(MYSQLPP_REFCOUNTED_H)
29 #define MYSQLPP_REFCOUNTED_H
79 template <
class T,
class Destroyer = RefCountedPo
interDestroyer<T> >
104 std::auto_ptr<T> exception_guard(counted_);
106 refs_ =
new size_t(1);
108 exception_guard.release();
113 counted_(other.counted_),
114 refs_(other.counted_ ? other.refs_ : 0)
127 if (refs_ && (--(*refs_) == 0)) {
128 Destroyer()(counted_);
224 operator const void*()
const
247 std::swap(counted_, other.counted_);
248 std::swap(refs_, other.refs_);
266 #endif // !defined(MYSQLPP_REFCOUNTED_H)
T * raw()
Return the raw pointer in T* context.
Definition: refcounted.h:230
~RefCountedPointer()
Destructor.
Definition: refcounted.h:125
RefCountedPointer(const ThisType &other)
Copy constructor.
Definition: refcounted.h:112
void swap(ThisType &other)
Exchange our managed memory with another pointer.
Definition: refcounted.h:245
Functor to call delete on the pointer you pass to it.
Definition: refcounted.h:45
RefCountedPointer(T *c)
Standard constructor.
Definition: refcounted.h:100
void operator()(T *doomed) const
Functor implementation.
Definition: refcounted.h:48
const T * raw() const
Return the raw pointer when used in const T* context.
Definition: refcounted.h:236
ThisType & assign(const ThisType &other)
Copy an existing refcounted pointer.
Definition: refcounted.h:157
RefCountedPointer< T > ThisType
alias for this object's type
Definition: refcounted.h:83
T & operator*() const
Dereference the smart pointer.
Definition: refcounted.h:192
Creates an object that acts as a reference-counted pointer to another object.
Definition: refcounted.h:80
ThisType & assign(T *c)
Sets (or resets) the pointer to the counted object.
Definition: refcounted.h:140
T * operator->() const
Access the object through the smart pointer.
Definition: refcounted.h:186
RefCountedPointer()
Default constructor.
Definition: refcounted.h:89
ThisType & operator=(T *c)
Set (or reset) the pointer to the counted object.
Definition: refcounted.h:170