|
Geogram Version 1.9.7
A programming library of geometric algorithms
|
A smart pointer with reference-counted copy semantics. More...
#include <geogram/basic/smart_pointer.h>
Public Member Functions | |
| SmartPointer () | |
| Creates an empty smart pointer. | |
| SmartPointer (T *ptr) | |
| Creates a smart pointer that owns a pointer. | |
| SmartPointer (const SmartPointer< T > &rhs) | |
| Create a copy of a smart pointer. | |
| ~SmartPointer () | |
| Deletes a smart pointer. | |
| SmartPointer< T > & | operator= (T *ptr) |
| Assignment from a pointer. | |
| SmartPointer< T > & | operator= (const SmartPointer< T > &rhs) |
| Assignment from a smart pointer. | |
| void | reset () |
| Resets pointer. | |
| T * | operator-> () const |
| Dereferences object member. | |
| T & | operator* () const |
| Dereferences object. | |
| operator T* () const | |
| Conversion operator. | |
| T * | get () const |
| Get pointer. | |
| bool | is_null () const |
| Check if stored pointer is null. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| template<class T1 , class T2 > | |
| bool | operator== (const SmartPointer< T1 > &lhs, const SmartPointer< T2 > &rhs) |
| Equal operator. | |
| template<class T1 , class T2 > | |
| bool | operator!= (const SmartPointer< T1 > &lhs, const SmartPointer< T2 > &rhs) |
| Not equal operator. | |
| template<class T1 , class T2 > | |
| bool | operator< (const SmartPointer< T1 > &lhs, const SmartPointer< T2 > &rhs) |
| Less than operator. | |
| template<class T1 , class T2 > | |
| bool | operator<= (const SmartPointer< T1 > &lhs, const SmartPointer< T2 > &rhs) |
| Less or equal operator. | |
| template<class T1 , class T2 > | |
| bool | operator> (const SmartPointer< T1 > &lhs, const SmartPointer< T2 > &rhs) |
| Greater than operator. | |
| template<class T1 , class T2 > | |
| bool | operator>= (const SmartPointer< T1 > &lhs, const SmartPointer< T2 > &rhs) |
| Greater or equal operator. | |
A smart pointer with reference-counted copy semantics.
| T | the type of pointers stored in the SmartPointer. |
SmartPointers have the ability of taking ownership of a pointer of type T and share that ownership: once they take ownership, the group of owners of a pointer become responsible for its deletion when the last one of them releases that ownership.
The object pointed to must implement the two following static functions:
More specifically, SmartPointer can be used with classes inheriting the Counted class.
Definition at line 76 of file smart_pointer.h.
|
inline |
Creates an empty smart pointer.
Definition at line 81 of file smart_pointer.h.
|
inline |
Creates a smart pointer that owns a pointer.
This calls T::ref() on the pointer ptr to take ownership on it.
| [in] | ptr | source pointer convertible to T* |
Definition at line 91 of file smart_pointer.h.
|
inline |
Create a copy of a smart pointer.
This calls T::ref() on the pointer help by rhs to take ownership on it.
| [in] | rhs | the smart pointer to copy |
Definition at line 102 of file smart_pointer.h.
|
inline |
Deletes a smart pointer.
This calls T::unref() to release ownership on the help pointer. If this smart pointer is the last one owning the pointer, the pointer is deleted.
Definition at line 113 of file smart_pointer.h.
|
inline |
|
inline |
Check if stored pointer is null.
true if the stored pointer is null, false otherwise. Definition at line 206 of file smart_pointer.h.
|
inline |
|
inline |
Dereferences object.
Returns the stored pointer in order to dereference it. This member function shall not be called if the stored pointer is a null pointer.
Definition at line 181 of file smart_pointer.h.
|
inline |
Dereferences object member.
Returns the stored pointer in order to access one of its members. This member function shall not be called if the stored pointer is a null pointer.
Definition at line 169 of file smart_pointer.h.
|
inline |
Assignment from a smart pointer.
Releases ownership on the stored pointer as if reset() were called and takes ownership on the pointer stored in rhs.
| [in] | rhs | the smart pointer to copy |
Definition at line 140 of file smart_pointer.h.
|
inline |
Assignment from a pointer.
Releases ownership on the stored pointer as if reset() were called and takes ownership on ptr.
| [in] | ptr | a pointer convertible to T* |
Definition at line 124 of file smart_pointer.h.
|
inline |
Resets pointer.
Releases ownership on the help pointer and resets it to null. The smart pointer becomes as if it were default-constructed.
Definition at line 157 of file smart_pointer.h.
|
related |
Not equal operator.
| [in] | lhs | the first pointer to compare |
| [in] | rhs | the second pointer to compare |
true if the pointer stored in lhs is not equal to the pointer stored in rhs. Definition at line 238 of file smart_pointer.h.
|
related |
Less than operator.
| [in] | lhs | the first pointer to compare |
| [in] | rhs | the second pointer to compare |
true if the pointer stored in lhs is less than the pointer stored in rhs. Definition at line 253 of file smart_pointer.h.
|
related |
Less or equal operator.
| [in] | lhs | the first pointer to compare |
| [in] | rhs | the second pointer to compare |
true if the pointer stored in lhs is less than or equal to the pointer stored in rhs. Definition at line 268 of file smart_pointer.h.
|
related |
Equal operator.
| [in] | lhs | the first pointer to compare |
| [in] | rhs | the second pointer to compare |
true if the pointer stored in lhs is equal to the pointer stored in rhs. Definition at line 223 of file smart_pointer.h.
|
related |
Greater than operator.
| [in] | lhs | the first pointer to compare |
| [in] | rhs | the second pointer to compare |
true if the pointer stored in lhs is greater than the pointer stored in rhs. Definition at line 283 of file smart_pointer.h.
|
related |
Greater or equal operator.
| [in] | lhs | the first pointer to compare |
| [in] | rhs | the second pointer to compare |
true if the pointer stored in lhs is greater than or equal to the pointer stored in rhs. Definition at line 298 of file smart_pointer.h.