28 #if !defined(MYSQLPP_REFCOUNTED_H)
29 #define MYSQLPP_REFCOUNTED_H
81 template <
class T,
class Destroyer = RefCountedPo
interDestroyer<T> >
106 UNIQUE_PTR(T) exception_guard(counted_);
108 refs_ =
new size_t(1);
110 exception_guard.release();
115 counted_(other.counted_),
116 refs_(other.counted_ ? other.refs_ : 0)
129 if (refs_ && (--(*refs_) == 0)) {
130 Destroyer()(counted_);
226 operator const void*()
const
249 std::swap(counted_, other.counted_);
250 std::swap(refs_, other.refs_);
Creates an object that acts as a reference-counted pointer to another object.
Definition: refcounted.h:83
RefCountedPointer()
Default constructor.
Definition: refcounted.h:91
T * raw()
Return the raw pointer in T* context.
Definition: refcounted.h:232
ThisType & operator=(T *c)
Set (or reset) the pointer to the counted object.
Definition: refcounted.h:172
RefCountedPointer(T *c)
Standard constructor.
Definition: refcounted.h:102
~RefCountedPointer()
Destructor.
Definition: refcounted.h:127
RefCountedPointer< T > ThisType
alias for this object's type
Definition: refcounted.h:85
ThisType & assign(const ThisType &other)
Copy an existing refcounted pointer.
Definition: refcounted.h:159
T & operator*() const
Dereference the smart pointer.
Definition: refcounted.h:194
ThisType & assign(T *c)
Sets (or resets) the pointer to the counted object.
Definition: refcounted.h:142
void swap(ThisType &other)
Exchange our managed memory with another pointer.
Definition: refcounted.h:247
const T * raw() const
Return the raw pointer when used in const T* context.
Definition: refcounted.h:238
RefCountedPointer(const ThisType &other)
Copy constructor.
Definition: refcounted.h:114
T * operator->() const
Access the object through the smart pointer.
Definition: refcounted.h:188
This file includes top-level definitions for use both internal to the library, and outside it....
Functor to call delete on the pointer you pass to it.
Definition: refcounted.h:48
void operator()(T *doomed) const
Functor implementation.
Definition: refcounted.h:50