Reference counting helper. More...
#include <object.h>
Public Member Functions | |
T * | get_ptr () |
Return a const pointer to the referenced object. More... | |
const T * | get_ptr () const |
Return a pointer to the referenced object. More... | |
operator T* () | |
Return a pointer to the referenced object. More... | |
bool | operator!= (const ref &r) const |
Compare this reference with another reference. More... | |
bool | operator!= (const T *ptr) const |
Compare this reference with a pointer. More... | |
T & | operator* () |
Return a C++ reference to the referenced object. More... | |
const T & | operator* () const |
Return a const C++ reference to the referenced object. More... | |
T * | operator-> () |
Access the object referenced by this reference. More... | |
const T * | operator-> () const |
Access the object referenced by this reference. More... | |
ref & | operator= (ref &&r) noexcept |
Move another reference into the current one. More... | |
ref & | operator= (const ref &r) |
Overwrite this reference with another reference. More... | |
ref & | operator= (T *ptr) |
Overwrite this reference with a pointer to another object. More... | |
bool | operator== (const ref &r) const |
Compare this reference with another reference. More... | |
bool | operator== (const T *ptr) const |
Compare this reference with a pointer. More... | |
ref () | |
Create a nullptr reference. More... | |
ref (T *ptr) | |
Construct a reference from a pointer. More... | |
ref (const ref &r) | |
Copy constructor. More... | |
ref (ref &&r) noexcept | |
Move constructor. More... | |
~ref () | |
Destroy this reference. More... | |
Private Attributes | |
T * | m_ptr |
Reference counting helper.
The ref refeference template is a simple wrapper to store a pointer to an object. It takes care of increasing and decreasing the reference count of the object. When the last reference goes out of scope, the associated object will be deallocated.