a pointer to a Mortal
object that will be updated if the object is destroyed or moved.
More...
#include <Mortal.hpp>
Public Member Functions | |
Mortal_ptr (T *data=nullptr) | |
constructs a Mortal_ptr that points to data | |
void | set (T *data=nullptr) |
constructs a Mortal_ptr that points to data | |
T * | get () |
obtains the raw address of the variable this points to | |
const T * | get () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
![]() | |
operator bool () const | |
returns true iff this is not null | |
T & | operator* () |
obtains a reference to the object this points to | |
T * | operator-> () |
accesses the members of the object this points to | |
T & | value () |
obtains a reference to the object this points to | |
const T & | operator* () const |
obtains a reference to the object this points to | |
const T * | operator-> () const |
accesses the members of the object this points to | |
const T & | value () const |
obtains a reference to the object this points to | |
Additional Inherited Members | |
![]() | |
Single () | |
Constructs a Single with no partner (it is "unpaired") | |
Single (const Single &)=delete | |
Single (Single &&that) | |
steals that 's partner, if it has one, leaving that unpaired | |
Single & | operator= (const Single &)=delete |
Single & | operator= (Single &&that) |
disconnects this from its partner, if it has one, and steals that 's, if it has one | |
void | pair (Base< void, void > &that) |
mutually connects this with that | |
void | unpair () |
mutually disconnects this from that | |
bool | paired () const |
returns true iff this is currently paired with a partner | |
Base< void, void > * | partner () |
provides access to this 's partner | |
const Base< void, void > * | partner () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
![]() | |
virtual void * | _mine () |
may be overridden by derrived classes to provide partners to data of some arbitrary type T | |
virtual const void * | _mine () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | _connect (Base< void, void > &that) |
mutually connects this and that by calling both of their _set() member functions | |
void | _disconnect (Base< void, void > &that) |
mutually disconnects this and that by calling both of their _unset() member functions | |
![]() | |
operator bool () const | |
returns true iff this is not null | |
T & | operator* () |
obtains a reference to the object this points to | |
T * | operator-> () |
accesses the members of the object this points to | |
T & | value () |
obtains a reference to the object this points to | |
const T & | operator* () const |
obtains a reference to the object this points to | |
const T * | operator-> () const |
accesses the members of the object this points to | |
const T & | value () const |
obtains a reference to the object this points to | |
![]() | |
static void * | _yours (Base< void, void > &that) |
Accesses the _mine() of that | |
static const void * | _yours (const Base< void, void > &that) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
a pointer to a Mortal
object that will be updated if the object is destroyed or moved.
If you have an object of type T
where T
is derived from Mortal
, then you can create a Mortal_ptr<T>
to it. If the object is moved, the Mortal_ptr
will be updated to point to it. If the object is destroyed, the Mortal_ptr
will become null. You can also move or destroy the Mortal_ptr
without any adverse consequences. As with any pointer object, if it is null, then dereferencing it will be undefined behavior and calling its value()
will throw an exception.
|
inlinevirtual |
obtains the raw address of the variable this
points to
Implements hexed::Pointer< T >.
|
inlinevirtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Implements hexed::Pointer< T >.