Maybe Result
 All Classes Functions
Public Types | Public Member Functions | Static Public Member Functions | List of all members
maybe::result< void, E > Class Template Referencefinal

Public Types

typedef void ok_type
 
typedef E err_type
 

Public Member Functions

 result (internal::placeholder, E &&value)
 
 result (internal::placeholder, const E &value)
 
 result (E &&value)
 
 result (const E &value)
 
bool is_ok () const noexcept
 
bool is_err () const noexcept
 
 operator bool () const noexcept
 
void ok_value ()
 
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 >
auto map (F f) noexcept-> maybe::result< typename std::result_of< F()>::type, 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< void, typename std::result_of< F(E)>::type >
 
template<typename U >
auto map_err_value (U value) noexcept-> maybe::result< void, U >
 
template<typename F >
auto and_then (F op) noexcept-> typename std::result_of< F()>::type
 
auto into_err () noexcept-> maybe::result< void, E >
 

Static Public Member Functions

static constexpr result< void, E > ok () noexcept
 
static constexpr result< void, E > err (E &&value) noexcept
 
static constexpr result< void, E > err (const E &value) noexcept
 
static constexpr result< void, E > default_ok () noexcept
 
static constexpr result< void, E > default_err () noexcept
 

Detailed Description

template<typename E>
class maybe::result< void, E >

Definition at line 315 of file result.hpp.

Member Function Documentation

template<typename E >
template<typename F >
auto maybe::result< void, E >::and_then ( op) -> typename std::result_of<F()>::type
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.

Parameters
fF() -> maybe::result<U, E>
Returns
maybe::result<U, E>

Definition at line 143 of file result.inline.hpp.

References maybe::result< T, E >::err().

template<typename E >
static constexpr result<void, E> maybe::result< void, E >::default_err ( )
inlinestaticnoexcept

Create a new err value using E() constructor.

Returns
result<void, E>

Definition at line 385 of file result.hpp.

template<typename E >
static constexpr result<void, E> maybe::result< void, E >::default_ok ( )
inlinestaticnoexcept

Create a new ok value using void() constructor.

Returns
result<void, E>

Definition at line 375 of file result.hpp.

template<typename E >
static constexpr result<void, E> maybe::result< void, E >::err ( E &&  value)
inlinestaticnoexcept

Create a new err value.

Parameters
Evalue
Returns
result<void, E>

Definition at line 360 of file result.hpp.

template<typename E >
auto maybe::result< void, E >::into_err ( ) -> maybe::result<void, E>
inlinenoexcept

Converts into another result with ok type void and forwards the same error.

Returns
maybe::result<void, E>

Definition at line 154 of file result.inline.hpp.

References maybe::result< T, E >::default_ok(), and maybe::result< T, E >::is_err().

template<typename E >
bool maybe::result< void, E >::is_err ( ) const
inlinenoexcept

Check if result contains err value.

Returns
bool

Definition at line 407 of file result.hpp.

template<typename E >
bool maybe::result< void, E >::is_ok ( ) const
inlinenoexcept

Check if result contains ok value.

Returns
bool

Definition at line 397 of file result.hpp.

template<typename E >
template<typename F >
auto maybe::result< void, E >::map ( f) -> maybe::result<typename std::result_of<F()>::type, E>
inlinenoexcept

Maps a result<void, E> to result<U, E> (where U is return value of F(void)) 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.

Parameters
fF() -> U
Returns
maybe::result<U, E>

Definition at line 95 of file result.inline.hpp.

template<typename E >
template<typename F >
auto maybe::result< void, E >::map_err ( f) -> maybe::result<void, typename std::result_of<F(E)>::type>
inlinenoexcept

Maps a result<void, E> to result<void, 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.

Parameters
fF(E) -> U
Returns
maybe::result<void, U>

Definition at line 119 of file result.inline.hpp.

template<typename E >
template<typename U >
auto maybe::result< void, E >::map_err_value ( value) -> maybe::result<void, U>
inlinenoexcept

Maps a result<void, E> to result<void, 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.

Parameters
valueU
Returns
maybe::result<void, U>

Definition at line 132 of file result.inline.hpp.

References maybe::result< T, E >::ok().

template<typename E >
template<typename U >
auto maybe::result< void, E >::map_value ( value) -> maybe::result<U, E>
inlinenoexcept

Maps a result<void, 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.

Parameters
valueU
Returns
maybe::result<U, E>

Definition at line 108 of file result.inline.hpp.

References maybe::result< T, E >::err().

template<typename E >
static constexpr result<void, E> maybe::result< void, E >::ok ( )
inlinestaticnoexcept

Create a new ok value.

Parameters
voidvalue
Returns
result<void, E>

Definition at line 349 of file result.hpp.


The documentation for this class was generated from the following files: