|
RPNX::DataStructures
Header-only C++ data structures and supporting utilities.
|
A generic result class that can hold either a value or an exception. More...
#include <result.hpp>
Public Member Functions | |
| result (T t) | |
| Constructs a result object with a value. | |
| result () | |
| Constructs an empty result object. | |
| result (std::exception_ptr er) | |
| Constructs a result object with an exception. | |
| void | test () const |
| Tests if the result contains an exception and rethrows it if present. | |
| T & | get () & |
| Returns the stored value from an lvalue result. | |
| T const & | get () const & |
| Returns the stored value from an lvalue result. | |
| T && | get () && |
| Returns the stored value from an rvalue result. | |
| T const && | get () const && |
| Returns the stored value from an rvalue result. | |
| T & | value () & |
Alias for get(). | |
| T const & | value () const & |
Alias for get(). | |
| T && | value () && |
Alias for rvalue-qualified get(). | |
| T const && | value () const && |
Alias for const rvalue-qualified get(). | |
| void | set_value (T t) |
| Sets the value of the result. | |
| void | set_error (std::exception_ptr er) |
| Sets the exception of the result. | |
| void | set_exception (std::exception_ptr er) |
Alias for set_error(). | |
| bool | has_result () const |
| Checks if the result has a value or an exception. | |
| bool | has_value () const |
| Checks if the result has a value. | |
| bool | has_error () const |
| Checks if the result has an exception. | |
| bool | has_exception () const |
Alias for has_error(). | |
| std::exception_ptr | get_error () const |
| Gets the stored exception. | |
| operator bool () const | |
| Implicit conversion to bool. | |
A generic result class that can hold either a value or an exception.
| T | The type of the value stored in the result. |
|
inline |
Constructs a result object with a value.
| t | The value to store in the result. |
|
inline |
Constructs a result object with an exception.
| er | The exception to store in the result. |
|
inline |
Returns the stored value from an lvalue result.
| The | stored exception when the result contains an error. |
|
inline |
Returns the stored value from an rvalue result.
| The | stored exception when the result contains an error. |
|
inline |
Returns the stored value from an lvalue result.
| The | stored exception when the result contains an error. |
|
inline |
Returns the stored value from an rvalue result.
| The | stored exception when the result contains an error. |
|
inline |
Gets the stored exception.
|
inline |
Checks if the result has an exception.
|
inline |
Alias for has_error().
true if an exception is stored.
|
inline |
Checks if the result has a value or an exception.
|
inline |
Checks if the result has a value.
|
inline |
Implicit conversion to bool.
|
inline |
Sets the exception of the result.
| er | The exception to set. |
|
inline |
Alias for set_error().
| er | Exception to store. |
|
inline |
Sets the value of the result.
| t | The value to set. |
|
inline |
Tests if the result contains an exception and rethrows it if present.
| The | stored exception if present. |
|
inline |
Alias for get().
|
inline |
Alias for rvalue-qualified get().
|
inline |
Alias for get().
|
inline |
Alias for const rvalue-qualified get().