Result<T, E> — either holds a T or an E, never both. More...
#include <result.hpp>
Public Types | |
| using | value_type = T |
| using | error_type = E |
Public Member Functions | |
| Result () | |
| Result (Ok< T > ok) | |
| Result (Err< E > err) | |
| Result (const Result &other) | |
| Result (Result &&other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_move_constructible_v< E >) | |
| Result & | operator= (const Result &other) |
| Result & | operator= (Result &&other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_move_constructible_v< E >) |
| ~Result () | |
| bool | has_value () const noexcept |
| operator bool () const noexcept | |
| bool | is_err () const noexcept |
| T & | value () & |
| const T & | value () const & |
| T && | value () && |
| T & | operator* () & |
| const T & | operator* () const & |
| T * | operator-> () |
| const T * | operator-> () const |
| template<typename U> | |
| T | value_or (U &&fallback) const & |
| Return the held value, or fallback when this is an error. | |
| E & | error () & |
| const E & | error () const & |
| E && | error () && |
Result<T, E> — either holds a T or an E, never both.
Inspired by Rust's Result and std::expected. T and E must be distinct types (avoids construct-from-ambiguity).
| using pulp::runtime::Result< T, E >::error_type = E |
| using pulp::runtime::Result< T, E >::value_type = T |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineexplicitnoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
Return the held value, or fallback when this is an error.