![]() |
Spicy
|
#include <reference.h>
Public Types | |
using | Base = std::weak_ptr< T > |
Public Member Functions | |
WeakReference ()=default | |
WeakReference (const ValueReference< T > &t) | |
WeakReference (const StrongReference< T > &t) | |
WeakReference (std::nullptr_t) | |
WeakReference (const WeakReference &other)=default | |
WeakReference (WeakReference &&other) noexcept=default | |
~WeakReference ()=default | |
bool | isNull () const |
bool | isExpired () const |
const T * | get () const |
ValueReference< T > | derefAsValue () const |
void | reset () |
const T & | operator* () const |
T & | operator* () |
const T * | operator-> () const |
T * | operator-> () |
operator bool () const | |
WeakReference & | operator= (const ValueReference< T > &other) |
WeakReference & | operator= (const StrongReference< T > &other) |
WeakReference & | operator= (std::nullptr_t) noexcept |
WeakReference & | operator= (const WeakReference &other) |
WeakReference & | operator= (WeakReference &&other) noexcept |
A weak reference to a shared value. This is essentially a weak_ptr
that can bind to the values of ValueReference
or StrongReference.
The weak reference will remain valid until all linked strong/value references have ceased to exist.
Note that different from ValueReference
, a weak reference can explicitly be null.
|
default |
Default constructor creating a null reference.
|
inlineexplicit |
Instantiates a reference pointing to the value referred to be an existing ValueReference
. This does not copy the value, it will be shared afterwards.
|
inlineexplicit |
Instantiates a reference pointing to the value referred to be an existing StrongReference
. This does not copy the value, it will be shared afterwards.
|
inlineexplicit |
Instantiate an unset reference.
|
default |
Copy constructor. This copies the reference, not the value, which will be shared afterwards.
|
defaultnoexcept |
Move constructor.
|
default |
Destructor.
|
inline |
Returns a value reference that is linked to the referred value. If the weak reference is null or expired, the returned reference will be null.
|
inline |
Returns a pointer to the value being referred to. This will be null if the weak point is null or expired.
|
inline |
Returns true if the reference was pointing to a non-null value that has now expired.
|
inline |
Returns true if the reference is either null or expired.
|
inlineexplicit |
Returns true if the reference is not null or expired.
|
inline |
Returns the contained value.
NullReference | or ExpiredReference if the instance is null or expired, respectively. |
|
inline |
Returns the contained value.
NullReference | or ExpiredReference if the instance is null or expired, respectively. |
|
inline |
Returns a pointer to the contained value.
NullReference | or ExpiredReference if the instance is null or expired, respectively. |
|
inline |
Returns a pointer to the contained value.
NullReference | or ExpiredReference if the instance is null or expired, respectively. |
|
inline |
Reinitialize the reference to now point to to the value referred to be an existing ValueReference
. This does not copy that value, it will be shared afterwards.
|
inline |
Reinitialize the reference to now point to to the value referred to be an existing StrongReference
. This does not copy that value, it will be shared afterwards.
|
inlinenoexcept |
Reset pointer.
|
inline |
Copy assignment. This will share ownership, not copy the value.
|
inlinenoexcept |
Move assignment.
|
inline |
Resets the reference to a null value.