![]() |
Spicy
|
#include <result.h>
Public Member Functions | |
| Result (const T &t) | |
| Result (T &&t) | |
| Result (const result::Error &e) | |
| Result (result::Error &&e) | |
| Result (const Result &o)=default | |
| Result (Result &&o)=default | |
| const T & | value () const |
| T & | value () |
| template<typename E = result::NoResult> | |
| const T & | valueOrThrow () const |
| template<typename E = result::NoResult> | |
| T & | valueOrThrow () |
| const result::Error & | error () const |
| const result::Error & | errorOrThrow () const |
| bool | hasValue () const |
| const T & | operator* () const |
| T & | operator* () |
| const T * | operator-> () const |
| T * | operator-> () |
| operator bool () const | |
| operator std::optional< T > () const | |
| Result & | operator= (const Result &other)=default |
| Result & | operator= (Result &&other)=default |
Friends | |
| bool | operator== (const Result &a, const Result &b) |
| bool | operator!= (const Result &a, const Result &b) |
Represents either a successful result from function if it returned one, or reflects an error if the function was unsuccessful.
|
inline |
Creates a successful result from a value.
|
inline |
Creates a successful result from a value.
|
inline |
Creates an result reflecting an error.
|
inline |
Creates an result reflecting an error.
|
inline |
Returns the result's error, assuming it reflect one.
| <tt>std::bad_variant_access</tt> | if the result doe not reflect an error state |
|
inline |
Returns the result's error if it indicates failure, or throws an exception if not.
| <tt>result::NoError</tt> | if the result does not reflect an error state |
|
inline |
Returns true if the result represents a successful return value.
|
inlineexplicit |
Returns true if the result represents a successful return value.
|
inline |
Converts the result to an optional that's set if it represents a successful return value.
|
inline |
Returns the result's value, assuming it indicates success.
|
inline |
Returns the result's value, assuming it indicates success.
|
inline |
Returns the result's value, assuming it indicates success.
|
inline |
Returns the result's value, assuming it indicates success.
|
inline |
Returns the result's value, assuming it indicates success.
| <tt>std::bad_variant_access</tt> | if the result reflects an error state |
|
inline |
Returns the result's value, assuming it indicates success.
| <tt>std::bad_variant_access</tt> | if the result reflects an error state |
|
inline |
Returns the result's value if it indicates success, or throws an exception if not.
| E | type of the exception to throw |
| exception | of type E if the result reflects an error state |
|
inline |
Returns the result's value if it indicates success, or throws an exception if not. By default, the exception thrown is result::NoResult.
| E | type of the exception to throw |
| exception | of type E if the result reflects an error state |