#include <Puma/SmartPtr.h>
template<class T>
class Puma::SmartPtr< T >
Template based smart pointer implementation.
Classes must be derived from SmartPtr::RefCnt to be compatible with this implementation. Example:
};
Reference counter for objects used with SmartPtr.
Definition SmartPtr.h:44
Template based smart pointer implementation.
Definition SmartPtr.h:40
SmartPtr()
Construct an empty smart pointer.
Definition SmartPtr.h:59
|
| SmartPtr () |
| Construct an empty smart pointer.
|
|
| SmartPtr (const RefCnt *pointer) |
| Construct a new smart pointer.
|
|
| SmartPtr (const SmartPtr ©) |
| Copy a smart pointer.
|
|
| ~SmartPtr () |
| Destroy the smart pointer.
|
|
void | clear () |
| Clear this smart pointer.
|
|
bool | valid () const |
| Check whether the smart pointer is valid.
|
|
bool | operator== (const SmartPtr &other) const |
| Compare this smart pointer with another smart pointer.
|
|
SmartPtr & | operator= (const SmartPtr ©) |
| Assign a new object to this smart pointer.
|
|
SmartPtr & | operator= (const RefCnt *copy) |
| Assign a new object to this smart pointer.
|
|
| operator bool () const |
| Conversion operator to check whether the smart pointer is valid.
|
|
| operator T* () const |
| Conversion operator for the managed object pointer type.
|
|
| operator const T * () const |
| Conversion operator for the managed object pointer type.
|
|
T * | operator-> () |
| Dereference operator for the managed object pointer type.
|
|
const T * | operator-> () const |
| Dereference operator for the managed object pointer type.
|
|
T * | operator* () |
| Indirection operator for the managed object pointer type.
|
|
const T * | operator* () const |
| Indirection operator for the managed object pointer type.
|
|
◆ SmartPtr() [1/3]
Construct an empty smart pointer.
◆ SmartPtr() [2/3]
Construct a new smart pointer.
- Parameters
-
pointer | A pointer to the object to manage. |
◆ SmartPtr() [3/3]
Copy a smart pointer.
Increases the reference count of the managed object.
- Parameters
-
copy | The smart pointer to copy. |
◆ ~SmartPtr()
Destroy the smart pointer.
If this was the last smart pointer referencing the managed object, the object is destroyed too.
◆ clear()
Clear this smart pointer.
If this was the last smart pointer referencing the managed object, the object is destroyed.
◆ operator bool()
Conversion operator to check whether the smart pointer is valid.
- Returns
- True if valid.
◆ operator const T *()
Conversion operator for the managed object pointer type.
- Returns
- A constant pointer to the managed object.
◆ operator T*()
Conversion operator for the managed object pointer type.
- Returns
- A pointer to the managed object.
◆ operator*() [1/2]
Indirection operator for the managed object pointer type.
- Returns
- A pointer to the managed object.
◆ operator*() [2/2]
Indirection operator for the managed object pointer type.
- Returns
- A constant pointer to the managed object.
◆ operator->() [1/2]
Dereference operator for the managed object pointer type.
- Returns
- A pointer to the managed object.
◆ operator->() [2/2]
Dereference operator for the managed object pointer type.
- Returns
- A constant pointer to the managed object.
◆ operator=() [1/2]
Assign a new object to this smart pointer.
If this smart pointer already points to an object, then this object might be destroyed if not referenced by another smart pointer.
- Parameters
-
copy | The smart pointer to copy. |
- Returns
- A reference to this smart pointer.
◆ operator=() [2/2]
Assign a new object to this smart pointer.
If this smart pointer already points to an object, then this object might be destroyed if not referenced by another smart pointer.
- Parameters
-
copy | The smart pointer to copy. |
- Returns
- A reference to this smart pointer.
◆ operator==()
Compare this smart pointer with another smart pointer.
- Parameters
-
other | The smart pointer to compare with. |
- Returns
- True if both smart pointers point to the same object.
◆ valid()
Check whether the smart pointer is valid.
A smart pointer is valid if the managed pointer isn't NULL.
- Returns
- True if valid.