Claw
1.7.3
|
A pointer with a reference counter. More...
#include <smart_ptr.hpp>
Public Types | |
typedef T | value_type |
The type of the pointed data. | |
typedef smart_ptr< value_type > | self_type |
The type of the current class. | |
typedef T & | reference |
Reference on the type of the stored data. | |
typedef T * | pointer |
Pointer on the type of the stored data. | |
typedef const T & | const_reference |
Constant reference on the type of the stored data. | |
typedef const T *const | const_pointer |
Constant pointer on the type of the stored data. |
Public Member Functions | |
smart_ptr () | |
Default constructor. | |
smart_ptr (pointer data) | |
Constructor from a pointer. | |
smart_ptr (const self_type &that) | |
Copy constructor. | |
~smart_ptr () | |
Destructor. The memory is freed only if no more smart_ptr point on it. | |
self_type & | operator= (const self_type &that) |
Assignment operator. | |
bool | operator== (const self_type &that) const |
Equality operator. | |
bool | operator!= (const self_type &that) const |
Disequality operator. | |
bool | operator< (const self_type &that) const |
"Less than" operator. | |
bool | operator<= (const self_type &that) const |
"Less or equal" operator. | |
bool | operator> (const self_type &that) const |
"Greater than" operator. | |
bool | operator>= (const self_type &that) const |
"Greater or equal" operator. | |
pointer | operator-> () |
Dereference operator. | |
pointer | operator-> () const |
Dereference operator. | |
reference | operator* () |
Dereference operator. | |
reference | operator* () const |
Dereference operator. |
A pointer with a reference counter.
Smart pointers allow the user to stop caring about the release of dynamically allocated memory. When no more pointers point to the allocated memory, this memory is released.
Template parameters:
Definition at line 51 of file smart_ptr.hpp.
claw::memory::smart_ptr< T >::smart_ptr | ( | pointer | data | ) |
Constructor from a pointer.
data | Pointer on the data. |
Warning: this constructor allows expressions like
int a; smart_ptr<int> p(&a);
Nevertheless, you should never fo that.
Definition at line 56 of file smart_ptr.tpp.
claw::memory::smart_ptr< T >::smart_ptr | ( | const self_type & | that | ) |
Copy constructor.
that | The smart_pointer to copy. |
Definition at line 72 of file smart_ptr.tpp.
bool claw::memory::smart_ptr< T >::operator!= | ( | const self_type & | that | ) | const |
Disequality operator.
that | The pointer to compare to. |
Definition at line 124 of file smart_ptr.tpp.
bool claw::memory::smart_ptr< T >::operator< | ( | const self_type & | that | ) | const |
"Less than" operator.
that | The pointer to compare to. |
Definition at line 137 of file smart_ptr.tpp.
bool claw::memory::smart_ptr< T >::operator<= | ( | const self_type & | that | ) | const |
"Less or equal" operator.
that | The pointer to compare to. |
Definition at line 149 of file smart_ptr.tpp.
claw::memory::smart_ptr< T >::self_type & claw::memory::smart_ptr< T >::operator= | ( | const self_type & | that | ) |
Assignment operator.
that | The smart_ptr to copy. |
Definition at line 94 of file smart_ptr.tpp.
bool claw::memory::smart_ptr< T >::operator== | ( | const self_type & | that | ) | const |
Equality operator.
that | The pointer to compare to. |
Definition at line 112 of file smart_ptr.tpp.
bool claw::memory::smart_ptr< T >::operator> | ( | const self_type & | that | ) | const |
"Greater than" operator.
that | The pointer to compare to. |
Definition at line 161 of file smart_ptr.tpp.
bool claw::memory::smart_ptr< T >::operator>= | ( | const self_type & | that | ) | const |
"Greater or equal" operator.
that | The pointer to compare to. |
Definition at line 173 of file smart_ptr.tpp.