CheckedWeakPointer
class CheckedWeakPointer
A weak pointer that throws an exception when it has expired.
This class behaves like a std::weak_ptr, except that it distinguishes between having been initialized with a valid pointer that expired and having been initialized with a nullptr.
When the pointer has expired, it throws an exception when trying to access the pointer, e. g. via lock().
constructor CheckedWeakPointer
Create an empty checked weak pointer.
| CheckedWeakPointer | ( | ); |
constructor CheckedWeakPointer
Create a checked weak pointer pointing to an object.
| CheckedWeakPointer | ( | std::weak_ptr< T > weak_ptr | ); |
| PARAMETER | DESCRIPTION |
|---|---|
weak_ptr |
The weak pointer to create the checked weak pointer from. |
method emptyconst
Check if the checked weak pointer was initialized with a nullptr.
| bool empty | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method expiredconst
Check if the checked weak pointer has expired, i.e. it was set but the referenced object has been destroyed.
| bool expired | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method lockconst
Lock the checked weak pointer and obtain a shared pointer.
| std::shared_ptr< T > lock | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::shared_ptr< T > |
A shared pointer to the managed object. |
| THROWS | DESCRIPTION |
|---|---|
Exception |
if the checked weak pointer has expired. |
method operator boolconst
Interpret as bool, i. e. check if the checked weak pointer was not initialized with a nullptr.
| operator bool | ( | ) const; |
method operator=
Assign a checked weak pointer to another.
| CheckedWeakPointer< T > & operator= | ( | CheckedWeakPointer< T > other | ); |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The checked weak pointer to assign from. |
| RETURNS | DESCRIPTION |
|---|---|
CheckedWeakPointer< T > & |
A reference to this checked weak pointer. |
method operator=
Assign a weak pointer.
| CheckedWeakPointer< T > & operator= | ( | std::weak_ptr< T > weak_ptr | ); |
| PARAMETER | DESCRIPTION |
|---|---|
weak_ptr |
The weak pointer to assign from. |
| RETURNS | DESCRIPTION |
|---|---|
CheckedWeakPointer< T > & |
A reference to this checked weak pointer. |
method operator==const
Compare with another checked weak pointer.
| bool operator== | ( | const CheckedWeakPointer< T > & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The checked weak pointer to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator==const
Compare with a shared pointer.
| bool operator== | ( | const std::shared_ptr< T > & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The shared pointer to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator==const
Compare with a weak pointer.
| bool operator== | ( | const std::weak_ptr< T > & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The weak pointer to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method reset
Reset the checked weak pointer to a nullptr.
| void reset | ( | ); |