Image Component Library (ICL)
|
Specialization of the SmartPtrBase class for Pointers. More...
#include <SmartPtr.h>
Public Types | |
typedef SmartPtrBase< T, PointerDelOp > | super |
Public Member Functions | |
SmartPtr () | |
creates a null pointer | |
template<class DerivedT > | |
SmartPtr (DerivedT *ptData, bool bOwn=true) | |
gets pointer, ownership is passed optionally | |
SmartPtr (T *ptData, bool bOwn=true) | |
gets pointer, ownership is passed optionally | |
template<class DerivedT > | |
SmartPtr (const SmartPtrBase< DerivedT, PointerDelOp > &r) | |
reference counting copy constructor | |
SmartPtr (const SmartPtrBase< T, PointerDelOp > &r) | |
reference counting copy constructor |
Specialization of the SmartPtrBase class for Pointers.
If the internal reference counter becomes 0, the contained data pointer is release using delete
class MyClass{...}; typedef SmartPtr<MyClass> MyClassPtr;
create an array of empty auto pointers MyClassPtr ps[100];
fill the first element of the array with one reference of type MyClass* ps[0] = new MyClass;
fill the other elements of the array with the SAME reference std::fill(ps+1,ps+100,ps[0])
reference counter is 100 now delete all except the last one for(int i=0;i<99;i++){ array[i].setNull(); }
now the reference counter of array[99] is 1, if it is deleted, the hold element is deleted as well array[99].setNull();
typedef SmartPtrBase<T,PointerDelOp> icl::utils::SmartPtr< T >::super |
icl::utils::SmartPtr< T >::SmartPtr | ( | ) | [inline] |
creates a null pointer
icl::utils::SmartPtr< T >::SmartPtr | ( | DerivedT * | ptData, |
bool | bOwn = true |
||
) | [inline] |
gets pointer, ownership is passed optionally
icl::utils::SmartPtr< T >::SmartPtr | ( | T * | ptData, |
bool | bOwn = true |
||
) | [inline] |
gets pointer, ownership is passed optionally
icl::utils::SmartPtr< T >::SmartPtr | ( | const SmartPtrBase< DerivedT, PointerDelOp > & | r | ) | [inline] |
reference counting copy constructor
icl::utils::SmartPtr< T >::SmartPtr | ( | const SmartPtrBase< T, PointerDelOp > & | r | ) | [inline] |
reference counting copy constructor