Base class for reference countable objects. More...
#include <refcount_ptr.h>
Public Member Functions | |
ReferenceCountable () | |
Default constructor, which initializes the reference count to zero. More... | |
~ReferenceCountable () | |
Friends | |
template<class T > | |
class | refcount_ptr |
Base class for reference countable objects.
Usage:
refcount_ptr<MyClass> myPtr = new MyClass(...);
where MyClass should have increase_refcount() and decrease_refcount(), e.g.
class MyClass : public ReferenceCountable { ... }
Note: Although MyClass objects can be created using the following syntax:
MyClass myobject(...);
this causes the object to have a reference count of 0. That is, the address should not be taken of such an object and exposed to the outside.
Implementation note: The counter itself is mutable, and the increase_refcount() and decrease_refcount() member functions are marked as const. This is because const objects also need to be properly reference counted.
Definition at line 62 of file refcount_ptr.h.
|
inline |
Default constructor, which initializes the reference count to zero.
Definition at line 69 of file refcount_ptr.h.
|
inline |
Definition at line 74 of file refcount_ptr.h.
|
friend |
Definition at line 83 of file refcount_ptr.h.