sprint 1-alpha
|
an intrusive shared_ptr implementation. More...
#include <shared_ptr.h>
Public Member Functions | |
shared_ptr (T *obj) | |
create a shared_ptr from an object. Increare reference count | |
shared_ptr (const shared_ptr< T > &obj) | |
create a shared_ptr from a shared_ptr. Increare reference count | |
template<class R > | |
shared_ptr (const shared_ptr< R > &obj) | |
create a shared_ptr from a shared_ptr. Increare reference count | |
~shared_ptr () | |
release shared_ptr | |
shared_ptr & | operator= (const shared_ptr< T > &a) |
T & | operator* () const |
T * | operator-> () const |
T * | get () const |
int | use_count () const |
for debug purpose returns the current reference count | |
void | swap (shared_ptr &b) |
an intrusive shared_ptr implementation.
Class T should have a m_refCount member (for example using sprint::sharable) in order to use sprint::shared_ptr. With this approach class have access to reference count and can switch between shared_ptr and pointer without restrictions. this class have the same size of an auto_ptr o a pointer, no heap fragmentation and waste, time to access to pointer is the same of a standard pointer. To help class development sprint::sharable object should be used.
sprint::shared_ptr<MyClass> p(new MyClass);