|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
A value of type T, or an error of type E, as std::expected.
More...
#include <expected.h>
Public Types | |
| using | value_type = T |
| The value's type. | |
| using | error_type = E |
| The error's type. | |
Public Member Functions | |
| Expected () | |
| A default-constructed value. | |
| Expected (const T &value) | |
Holds value. | |
| Expected (T &&value) | |
Holds value. | |
| template<typename G> | |
| Expected (const Unexpected< G > &error) | |
Holds error's error. | |
| template<typename G> | |
| Expected (Unexpected< G > &&error) | |
Holds error's error. | |
| bool | has_value () const noexcept |
| Whether it holds a value. | |
| operator bool () const noexcept | |
| Whether it holds a value. | |
| const T & | value () const & |
| The value; stops the program if it holds an error. | |
| T & | value () & |
| The value; stops the program if it holds an error. | |
| T && | value () && |
| The value, moved out; stops the program if it holds an error. | |
| const E & | error () const & |
| The error; it must hold one. | |
| E & | error () & |
| The error; it must hold one. | |
| E && | error () && |
| The error, moved out; it must hold one. | |
| const T & | operator* () const & |
| The value; it must hold one. | |
| T & | operator* () & |
| The value; it must hold one. | |
| T && | operator* () && |
| The value, moved out; it must hold one. | |
| const T * | operator-> () const |
| The value's members; it must hold one. | |
| T * | operator-> () |
| The value's members; it must hold one. | |
| template<typename U> | |
| T | value_or (U &&fallback) const & |
The value, or fallback if it holds an error. | |
| template<typename U> | |
| T | value_or (U &&fallback) && |
The value moved out, or fallback if it holds an error. | |
Static Private Member Functions | |
| template<typename G> | |
| static QString | messageOf (const G &error) |
| The message of an Error, for badExpectedAccess(); other error types have none. | |
Private Attributes | |
| std::variant< T, E > | m_v |
| The value (index 0) or the error (index 1). | |
A value of type T, or an error of type E, as std::expected.
Converts to true if it holds a value. value() and operator* on an error, and error() on a value, are mistakes: value() stops the program with the error's message (std::expected throws), and the others assert.