Template Class Expected< void >#
Defined in File expected.h
Class Documentation#
-
template<>
class Expected<void># Specialization of Expected for a successful operation without a value.
Expected<void> stores FFI None when successful and an Error when unsuccessful. A successful value is constructed with the default constructor, and value validates success without returning a value.
Public Functions
-
~Expected() = default#
-
Expected() = default#
Construct a successful Expected<void>.
-
inline Expected(Error error)#
Implicit constructor from an error.
- Parameters:
error – The error value.
-
template<typename E, typename = std::enable_if_t<std::is_base_of_v<Error, std::remove_cv_t<E>>>>
inline Expected(Unexpected<E> unexpected)# Implicit constructor from an Unexpected wrapper.
-
inline int32_t type_index() const noexcept#
Return the raw stored type index.
-
inline void value() const &#
Validate successful completion, or throw the contained error.
-
inline void value() &&#
Validate successful completion, or throw the contained error by move.
-
inline Error error() &&#
Returns the contained error (moved out), or throws RuntimeError if is_ok().
-
inline Expected<U> as_or_error() const &#
Strictly reinterpret the success value as U, or return an error.
Note
This function does not perform value conversions. The source is preserved.
- Template Parameters:
U – An unqualified owning storage type, excluding Error and its subclasses and void.
- Returns:
A copy of the stored value or existing error, or TypeError on a type mismatch.
-
~Expected() = default#