BoB robotics
The Brains on Board robotics library
ref< T > Class Template Reference

Reference counting helper. More...

#include <object.h>

Public Member Functions

 ref ()
 Create a nullptr reference.
 
 ref (T *ptr)
 Construct a reference from a pointer.
 
 ref (const ref &r)
 Copy constructor.
 
 ref (ref &&r) noexcept
 Move constructor.
 
 ~ref ()
 Destroy this reference.
 
refoperator= (ref &&r) noexcept
 Move another reference into the current one.
 
refoperator= (const ref &r)
 Overwrite this reference with another reference.
 
refoperator= (T *ptr)
 Overwrite this reference with a pointer to another object.
 
bool operator== (const ref &r) const
 Compare this reference with another reference.
 
bool operator!= (const ref &r) const
 Compare this reference with another reference.
 
bool operator== (const T *ptr) const
 Compare this reference with a pointer.
 
bool operator!= (const T *ptr) const
 Compare this reference with a pointer.
 
T * operator-> ()
 Access the object referenced by this reference.
 
const T * operator-> () const
 Access the object referenced by this reference.
 
T & operator* ()
 Return a C++ reference to the referenced object.
 
const T & operator* () const
 Return a const C++ reference to the referenced object.
 
 operator T* ()
 Return a pointer to the referenced object.
 
T * get_ptr ()
 Return a const pointer to the referenced object.
 
const T * get_ptr () const
 Return a pointer to the referenced object.
 

Detailed Description

template<typename T>
class ref< T >

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.


The documentation for this class was generated from the following file: