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_);
268 #endif // !defined(MYSQLPP_REFCOUNTED_H) T * raw()
Return the raw pointer in T* context.
Definition: refcounted.h:232
~RefCountedPointer()
Destructor.
Definition: refcounted.h:127
RefCountedPointer(const ThisType &other)
Copy constructor.
Definition: refcounted.h:114
void swap(ThisType &other)
Exchange our managed memory with another pointer.
Definition: refcounted.h:247
Functor to call delete on the pointer you pass to it.
Definition: refcounted.h:47
const T * raw() const
Return the raw pointer when used in const T* context.
Definition: refcounted.h:238
RefCountedPointer(T *c)
Standard constructor.
Definition: refcounted.h:102
void operator()(T *doomed) const
Functor implementation.
Definition: refcounted.h:50
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
RefCountedPointer< T > ThisType
alias for this object's type
Definition: refcounted.h:85
Creates an object that acts as a reference-counted pointer to another object.
Definition: refcounted.h:82
This file includes top-level definitions for use both internal to the library, and outside it....
ThisType & assign(T *c)
Sets (or resets) the pointer to the counted object.
Definition: refcounted.h:142
T * operator ->() const
Access the object through the smart pointer.
Definition: refcounted.h:188
RefCountedPointer()
Default constructor.
Definition: refcounted.h:91
ThisType & operator=(T *c)
Set (or reset) the pointer to the counted object.
Definition: refcounted.h:172