#include <yat/utility/SmartPtr.h>
Public Member Functions | |
SmartPtr (T *p=NULL, bool owner=true) | |
Constructor. | |
SmartPtr (const SmartPtr &other) | |
Copy constructor. | |
virtual | ~SmartPtr () |
Destructor. | |
SmartPtr & | operator= (const SmartPtr &rhs) |
T * | operator-> (void) const |
T & | operator* (void) const |
theplu::yat::utility::SmartPtr< T >::SmartPtr | ( | T * | p = NULL , |
|
bool | owner = true | |||
) | [inline, explicit] |
Constructor.
p | underlying pointer | |
owner | if true SmartPtr will be owner of pointer and if there is no more owner delete it in destructor. |
MyClass* my_pointer = new MyClass; SmartPtr<MyClass> sp(my_pointer); SmartPtr<MyClass> sp2(my_pointer); // this is evil
MyClass* my_pointer = new MyClass;
SmartPtr<MyClass> sp(my_pointer);
SmartPtr<MyClass> sp2(sp);
virtual theplu::yat::utility::SmartPtr< T >::~SmartPtr | ( | ) | [inline, virtual] |
Destructor.
If SmartPtr is owner and the only owner, underlying pointer is deleted.
T& theplu::yat::utility::SmartPtr< T >::operator* | ( | void | ) | const [inline] |
T* theplu::yat::utility::SmartPtr< T >::operator-> | ( | void | ) | const [inline] |
SmartPtr& theplu::yat::utility::SmartPtr< T >::operator= | ( | const SmartPtr< T > & | rhs | ) | [inline] |
If SmartPtr is owner and the only owner, underlying pointer is deleted.
If rhs is owner, lhs become also owner.