yat
0.20.3pre
|
#include <yat/utility/SmartPtr.h>
Public Member Functions | |
SmartPtr (T *p=NULL, bool owner=true) | |
Constructor. More... | |
SmartPtr (const SmartPtr &other) | |
Copy constructor. | |
virtual | ~SmartPtr () |
Destructor. More... | |
SmartPtr & | operator= (const SmartPtr &rhs) |
T * | operator-> (void) const |
T & | operator* (void) const |
SmartPtr is a wrapper around a pointer. Default SmartPtr is set to be owner of pointer, which implies pointer will be deleted in destructor. Pointer can be shared between many SmartPtr, in which case a counter is kept updated in copying and assignment telling how many owners there are. When the counter reaches zero, the pointer is deleted.
This is an internal class kept for backward compabitility. Users are adviced to use std::shared_ptr.
|
inlineexplicit |
Constructor.
p | underlying pointer |
owner | if true SmartPtr will be owner of pointer and if there is no more owner delete it in destructor. |
Never use this constructor to create two SmartPtr to the same pointer such as
since this will cause multiple deletion. Instead use copy constructor
so the internal reference counter is updated.
|
inlinevirtual |
Destructor.
If SmartPtr is owner and the only owner, underlying pointer is deleted.
|
inline |
|
inline |
|
inline |
If SmartPtr is owner and the only owner, underlying pointer is deleted.
If rhs is owner, lhs become also owner.