Sygaldry
|
Wrapper around a type T
with optional-like semantics and persistent state.
More...
Public Types | |
using | type = T |
The underlying type. | |
Public Member Functions | |
constexpr | occasional () noexcept |
Default constructor; state is default initialized and updated is false. | |
constexpr | occasional (occasional< T > &&other) |
Move constructor from another occasional . | |
constexpr | occasional (const occasional< T > &other) |
Copy constructor from another occasional . | |
constexpr auto & | operator= (occasional< T > &&other) |
Move assignment from another occasional . | |
constexpr auto & | operator= (const occasional< T > &other) |
Copy assignment from another occasional . | |
constexpr | operator T& () noexcept |
Mutable value access. | |
constexpr | operator const T & () const noexcept |
Immutable value access. | |
constexpr | occasional (T &&t) noexcept |
Move constructor from the underlying type. | |
constexpr | occasional (const T &t) noexcept |
Copy constructor from the underlying type. | |
constexpr auto & | operator= (T &&t) noexcept |
Move assignment from the underlying type. | |
constexpr auto & | operator= (const T &t) noexcept |
Copy assignment from the underlying type. | |
constexpr T & | operator* () noexcept |
Mutable dereference operator; provides access to the underlying state. | |
constexpr const T & | operator* () const noexcept |
Constant dereference operator; provides access to the underlying state. | |
constexpr T * | operator-> () noexcept |
Mutable member access operator; provides access to the members of the underlying state. | |
constexpr const T * | operator-> () const noexcept |
Constant member access operator; provides access to the members of the underlying state. | |
constexpr T & | value () noexcept |
Mutable value access. | |
constexpr const T & | value () const noexcept |
Immutable value access. | |
constexpr void | reset () noexcept |
Clear the updated flag. This can also be achieved by assignment from empty braces, e.g. x = {}; | |
Public Attributes | |
T | state |
The wrapped state. | |
bool | updated |
Flag indicating if the state has been changed. | |
Wrapper around a type T
with optional-like semantics and persistent state.
Intended to provide a means of developing message-like semantics while also allowing output messages to maintain state between loops, occasional
provides a conversion to bool
that indicates if the underlying wrapped state has been updated since the last time it was cleared. The runtime is meant to clear this flag between loops. However, the underlying state is not reset in this process.
Endpoints inheriting from this type should state using occasional<T>::operator=
to explicitly inherit the assignment operators from occasional
.