45 bool HasValue()
const {
return m_value.index() == 0; }
46 explicit operator bool()
const {
return HasValue(); }
50 T&
Value() {
return std::get<0>(m_value); }
51 const T&
Value()
const {
return std::get<0>(m_value); }
64 std::variant<T, Error> m_value;
80 explicit operator bool()
const {
return HasValue(); }
87 bool m_failed =
false;
bool HasValue() const
True on success; same as the bool conversion.
Definition gui_result.h:79
Result()=default
Default-constructed is success; implicit from an Error for failure.
Result(Error error)
Default-constructed is success; implicit from an Error for failure.
Definition gui_result.h:75
const Error & GetError() const
The error; a default Error on success.
Definition gui_result.h:83
T ValueOr(T fallback) const
A copy of the value, or fallback when there is none.
Definition gui_result.h:58
bool HasValue() const
True when it holds the value; same as the bool conversion.
Definition gui_result.h:45
T & Value()
The value; only valid when HasValue() (std::get throws otherwise).
Definition gui_result.h:50
const T * operator->() const
The value; only valid when HasValue() (std::get throws otherwise).
Definition gui_result.h:55
const T & operator*() const
The value; only valid when HasValue() (std::get throws otherwise).
Definition gui_result.h:53
const T & Value() const
The value; only valid when HasValue() (std::get throws otherwise).
Definition gui_result.h:51
T * operator->()
The value; only valid when HasValue() (std::get throws otherwise).
Definition gui_result.h:54
T & operator*()
The value; only valid when HasValue() (std::get throws otherwise).
Definition gui_result.h:52
const Error & GetError() const
The error; only valid when !HasValue().
Definition gui_result.h:61
ErrorCode
Why a call failed.
Definition gui_result.h:14
Result(T value)
Implicit from a value or an Error, so functions can return either.
Definition gui_result.h:40
Result(Error error)
Definition gui_result.h:41
@ ParseFailed
a theme, a layout
Definition gui_result.h:18
@ InvalidArgument
Definition gui_result.h:16
@ NotFound
a file, a device, an element
Definition gui_result.h:17
@ Unsupported
the device or backend lacks a feature
Definition gui_result.h:19
@ OutOfMemory
Definition gui_result.h:20
@ Failed
anything else; see the message
Definition gui_result.h:15
@ DeviceLost
the GPU device was lost (the library recreates it)
Definition gui_result.h:21
Definition gui_logging.h:24
A failure: its category and a human-readable message.
Definition gui_result.h:26
ErrorCode code
Definition gui_result.h:27
std::string message
what went wrong, for logs and users
Definition gui_result.h:28