Public Types | |
typedef T | ok_type |
typedef E | err_type |
Public Member Functions | |
result (T &&value, internal::placeholder) | |
result (internal::placeholder, E &&value) | |
result (const T &value, internal::placeholder) | |
result (internal::placeholder, const E &value) | |
bool | is_ok () const noexcept |
bool | is_err () const noexcept |
operator bool () const noexcept | |
constexpr T const & | ok_value () const & |
constexpr T & | ok_value ()& |
constexpr T && | ok_value ()&& |
template<class V > | |
constexpr T | ok_value_or (V &&v) const & |
template<class V > | |
constexpr T | ok_value_or (V &&v)&& |
constexpr E const & | err_value () const & |
constexpr E & | err_value ()& |
constexpr E && | err_value ()&& |
template<class V > | |
constexpr E | err_value_or (V &&v) const & |
template<class V > | |
constexpr E | err_value_or (V &&v)&& |
template<typename F , typename R = typename std::result_of<F(T)>::type> | |
auto | map (F f) noexcept-> maybe::result< R, E > |
auto | map_void () noexcept-> maybe::result< void, E > |
template<typename U > | |
auto | map_value (U value) noexcept-> maybe::result< U, E > |
template<typename F > | |
auto | map_err (F f) noexcept-> maybe::result< T, typename std::result_of< F(E)>::type > |
template<typename U > | |
auto | map_err_value (U value) noexcept-> maybe::result< T, U > |
template<typename F > | |
auto | and_then (F op) noexcept-> typename std::result_of< F(T)>::type |
template<typename U > | |
auto | into_err () noexcept-> maybe::result< U, E > const |
Static Public Member Functions | |
static constexpr result< T, E > | ok (T &&value) noexcept |
static constexpr result< T, E > | ok (const T &value) noexcept |
static constexpr result< T, E > | err (E &&value) noexcept |
static constexpr result< T, E > | err (const E &value) noexcept |
static constexpr result< T, E > | default_ok () noexcept |
static constexpr result< T, E > | default_err () noexcept |
Definition at line 15 of file result.fwd.hpp.
|
inlinenoexcept |
Calls op if the result is ok, otherwise returns the err value of self.
This function can be used for control flow based on result values.
f | F(T) -> maybe::result<U, E> |
Definition at line 73 of file result.inline.hpp.
References maybe::result< T, E >::err().
|
inlinestaticnoexcept |
Create a new err value using E()
constructor.
Definition at line 114 of file result.hpp.
|
inlinestaticnoexcept |
Create a new ok value using T()
constructor.
Definition at line 104 of file result.hpp.
Referenced by maybe::result< T, E >::into_err(), and maybe::result< void, E >::into_err().
|
inlinestaticnoexcept |
Create a new err value.
E | value |
Definition at line 88 of file result.hpp.
Referenced by maybe::result< T, E >::and_then(), maybe::result< void, E >::and_then(), maybe::result< T, E >::map(), maybe::result< T, E >::map_err_value(), maybe::result< T, E >::map_value(), maybe::result< void, E >::map_value(), and maybe::result< T, E >::map_void().
|
inlinenoexcept |
Converts into another result with different ok type U
and forwards the same error.
The ok type U
must have U()
constructor in case the result does not contain an err.
Definition at line 85 of file result.inline.hpp.
References maybe::result< T, E >::default_ok().
|
inlinenoexcept |
Check if result contains err value.
Definition at line 136 of file result.hpp.
Referenced by maybe::result< void, E >::into_err().
|
inlinenoexcept |
|
inlinenoexcept |
Maps a result<T, E> to result<U, E> (where U is return value of F(T)) by applying a function F to a contained ok value, leaving an err value untouched.
This function can be used to compose the results of two functions.
f | F(T) -> U |
Definition at line 17 of file result.inline.hpp.
References maybe::result< T, E >::err().
|
inlinenoexcept |
Maps a result<T, E> to result<T, U> (where U is return value of F(E)) by applying a function to a function to a contained err value, leaving an ok value untouched.
This function can be used to pass through a successful result while changing an error.
f | F(E) -> U |
Definition at line 49 of file result.inline.hpp.
|
inlinenoexcept |
Maps a result<T, E> to result<T, U> by always returning provided U value on error, leaving an ok value untouched.
This function can be used to compose the results of two functions.
value | U |
Definition at line 62 of file result.inline.hpp.
References maybe::result< T, E >::err().
|
inlinenoexcept |
Maps a result<T, E> to result<U, E> by always returning provided U value on success, leaving an err value untouched.
This function can be used to compose the results of two functions.
value | U |
Definition at line 38 of file result.inline.hpp.
References maybe::result< T, E >::err().
|
inlinenoexcept |
Maps a result<T, E> to result<void, E>, leaving an err value untouched.
Definition at line 27 of file result.inline.hpp.
References maybe::result< T, E >::err().
|
inlinestaticnoexcept |
Create a new ok value.
T | value |
Definition at line 71 of file result.hpp.
Referenced by maybe::result< void, E >::map_err_value().