#include <Pt/SmartPtr.h>
Policy based smart pointer. More...
Inherits OwnershipPolicy, and DestroyPolicy.
Public Member Functions | |
SmartPtr () | |
Default Constructor. More... | |
SmartPtr (T *ptr) | |
Constructs from a pointer to manage. | |
SmartPtr (const SmartPtr &ptr) | |
Copy constructor. | |
~SmartPtr () | |
Destructor. | |
T * | get () |
Get non-owning pointer. | |
const T * | get () const |
Get non-owning pointer. | |
operator bool () const | |
Returns true if the raw pointer is not null. | |
bool | operator! () const |
Returns true if the raw pointer is null. | |
T & | operator* () const |
Access value. | |
T * | operator-> () const |
Access value. | |
SmartPtr & | operator= (const SmartPtr &ptr) |
Assign from another SmartPtr. | |
Related Functions | |
template<typename T , typename M , typename D > | |
void | fixup (const Pt::FixupInfo &fixup, SmartPtr< T, M, D > &fixme) |
Custom fixup for deserialization. | |
template<typename T , typename M , typename D > | |
void | load (const LoadInfo &li, SmartPtr< T, M, D > &sp) |
Custom loading for deserialization. | |
template<typename T , typename O , typename D , typename T2 , typename O2 , typename D2 > | |
bool | operator!= (const SmartPtr< T, O, D > &a, const SmartPtr< T2, O2, D2 > &b) |
Equality comparison operator. | |
template<typename T , typename O , typename D , typename T2 > | |
bool | operator!= (const SmartPtr< T, O, D > &a, const T2 *b) |
Equality comparison operator. | |
template<typename T , typename O , typename D , typename T2 , typename O2 , typename D2 > | |
bool | operator< (const SmartPtr< T, O, D > &a, const SmartPtr< T2, O2, D2 > &b) |
Less-than comparison operator. | |
template<typename T , typename O , typename D , typename T2 > | |
bool | operator< (const SmartPtr< T, O, D > &a, const T2 *b) |
Less-than comparison operator. | |
template<typename T , typename M , typename D > | |
void | operator<<= (Pt::SerializationInfo &si, const SmartPtr< T, M, D > &sp) |
Serialize a smart pointer. | |
template<typename T , class O , typename D , typename T2 , typename O2 , typename D2 > | |
bool | operator== (const SmartPtr< T, O, D > &a, const SmartPtr< T2, O2, D2 > &b) |
Equality comparison operator. | |
template<typename T , typename O , typename D , typename T2 > | |
bool | operator== (const SmartPtr< T, O, D > &a, const T2 *b) |
Equality comparison operator. | |
template<typename T , typename M > | |
void | operator>>= (const Pt::SerializationInfo &si, SmartPtr< T, M > &sp) |
Deserialize a smart pointer. | |
template<typename T , typename M , typename D > | |
void | save (Pt::SaveInfo &si, const SmartPtr< T, M, D > &sp) |
Custom saving for serialization. | |
The SmartPtr implements a OwnershipPolicy that determines how the contained raw pointer is managed. The default is reference counting, which uses a non-intrusive reference counting mechanism. A OwnershipPolicy needs to implement two functions called link() and unlink() to manage a raw pointer. The DestroyPolicy implements the method for destroying the object once the smart pointer detects, that the object needs to be freed. By default the object is destroyed by deleting it, but this can be overridden by using a different DestroyPolicy. The DestroyPolicy needs to implement a method destroy(T*), which releases the underlying pointer.
T | Contained type. |
OwnershipPolicy | Manages ownership. |
DestroyPolicy | Destroys the object. |
SmartPtr | ( | ) |
The contained pointer is set to null in the default constructor.