CAF includes a few utility classes that are likely to be part of C++ eventually (or already are in newer versions of the standard). However, until these classes are part of the standard library on all supported compilers, we unfortunately have to maintain our own implementations.
Represents a value that may or may not exist.
Constructors | |
(T value) |
Constructs an object with a value. |
(none_t = none) |
Constructs an object without a value. |
Observers | |
explicit operator bool() |
Checks whether the object contains a value. |
T* operator->() |
Accesses the contained value. |
T& operator*() |
Accesses the contained value. |
Represents the result of a computation that should return a value. If no
value could be produced, the expected<T>
contains an
error
error_.
Constructors | |
(T value) |
Constructs an object with a value. |
(error err) |
Constructs an object with an error. |
Observers | |
explicit operator bool() |
Checks whether the object contains a value. |
T* operator->() |
Accesses the contained value. |
T& operator*() |
Accesses the contained value. |
error& error() |
Accesses the contained error. |
The constant unit
of type unit_t
is the equivalent of
void
and can be used to initialize optional<void>
and
expected<void>
.
The constant none
of type none_t
can be used to
initialize an optional<T>
to represent ``nothing''.