C++ Actor Framework 0.19
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Related Symbols | List of all members
caf::expected< T > Class Template Reference

Represents the result of a computation which can either complete successfully with an instance of type T or fail with an error. More...

#include <expected.hpp>

Public Types

using value_type = T
 
using error_type = caf::error
 
template<class U >
using rebind = expected< U >
 

Public Member Functions

template<class U , class = std::enable_if_t<std::is_convertible_v<U, T> || is_error_code_enum_v<U>>>
 expected (U x)
 
 expected (T &&x) noexcept(nothrow_move)
 
 expected (const T &x) noexcept(nothrow_copy)
 
 expected (caf::error e) noexcept
 
 expected (const expected &other) noexcept(nothrow_copy)
 
 expected (expected &&other) noexcept(nothrow_move)
 
template<class... Ts>
 expected (std::in_place_t, Ts &&... xs)
 
expectedoperator= (const expected &other) noexcept(nothrow_copy)
 
expectedoperator= (expected &&other) noexcept(nothrow_move)
 
expectedoperator= (const T &x) noexcept(nothrow_copy)
 
expectedoperator= (T &&x) noexcept(nothrow_move)
 
template<class U >
std::enable_if_t< std::is_convertible_v< U, T >, expected & > operator= (U x)
 
expectedoperator= (caf::error e) noexcept
 
template<class Enum , class = std::enable_if_t<is_error_code_enum_v<Enum>>>
expectedoperator= (Enum code)
 
 operator bool () const noexcept
 Returns true if the object holds a value (is engaged).
 
bool has_value () const noexcept
 Returns true if the object holds a value (is engaged).
 
bool engaged () const noexcept
 Returns true if the object holds a value (is engaged).
 
template<class... Args>
std::enable_if_t< std::is_nothrow_constructible_v< T, Args... >, T & > emplace (Args &&... args) noexcept
 
void swap (expected &other) noexcept(nothrow_move &&nothrow_swap)
 
const T & cvalue () const noexcept
 Returns the contained value.
 
T & value () &
 Returns the contained value.
 
const T & value () const &
 Returns the contained value.
 
T && value () &&
 Returns the contained value.
 
const T && value () const &&
 Returns the contained value.
 
template<class U >
value_or (U &&fallback) const &
 Returns the contained value if there is one, otherwise returns fallback.
 
template<class U >
value_or (U &&fallback) &&
 Returns the contained value if there is one, otherwise returns fallback.
 
T & operator* () &noexcept
 Returns the contained value.
 
const T & operator* () const &noexcept
 Returns the contained value.
 
T && operator* () &&noexcept
 Returns the contained value.
 
const T && operator* () const &&noexcept
 Returns the contained value.
 
T * operator-> () noexcept
 Returns the contained value.
 
const T * operator-> () const noexcept
 Returns the contained value.
 
const caf::errorcerror () const noexcept
 Returns the contained error.
 
caf::errorerror () &noexcept
 Returns the contained error.
 
const caf::errorerror () const &noexcept
 Returns the contained error.
 
caf::error && error () &&noexcept
 Returns the contained error.
 
const caf::error && error () const &&noexcept
 Returns the contained error.
 
template<class F >
auto and_then (F &&f) &
 
template<class F >
auto and_then (F &&f) &&
 
template<class F >
auto and_then (F &&f) const &
 
template<class F >
auto and_then (F &&f) const &&
 
template<class F >
expected or_else (F &&f) &
 
template<class F >
expected or_else (F &&f) &&
 
template<class F >
expected or_else (F &&f) const &
 
template<class F >
expected or_else (F &&f) const &&
 
template<class F >
auto transform (F &&f) &
 
template<class F >
auto transform (F &&f) &&
 
template<class F >
auto transform (F &&f) const &
 
template<class F >
auto transform (F &&f) const &&
 
template<class F >
expected transform_or (F &&f) &
 
template<class F >
expected transform_or (F &&f) &&
 
template<class F >
expected transform_or (F &&f) const &
 
template<class F >
expected transform_or (F &&f) const &&
 

Static Public Attributes

static constexpr bool nothrow_move
 Stores whether move construct and move assign never throw.
 
static constexpr bool nothrow_copy
 Stores whether copy construct and copy assign never throw.
 
static constexpr bool nothrow_swap = std::is_nothrow_swappable_v<T>
 Stores whether swap() never throws.
 

Related Symbols

(Note that these are not member symbols.)

template<class T >
auto operator== (const expected< T > &x, const expected< T > &y) -> decltype(*x==*y)
 
template<class T , class U >
auto operator== (const expected< T > &x, const U &y) -> decltype(*x==y)
 
template<class T , class U >
auto operator== (const T &x, const expected< U > &y) -> decltype(x==*y)
 
template<class T >
bool operator== (const expected< T > &x, const error &y)
 
template<class T >
bool operator== (const error &x, const expected< T > &y)
 
template<class T , class Enum >
std::enable_if_t< is_error_code_enum_v< Enum >, bool > operator== (const expected< T > &x, Enum y)
 
template<class T , class Enum >
std::enable_if_t< is_error_code_enum_v< Enum >, bool > operator== (Enum x, const expected< T > &y)
 
template<class T >
auto operator!= (const expected< T > &x, const expected< T > &y) -> decltype(*x==*y)
 
template<class T , class U >
auto operator!= (const expected< T > &x, const U &y) -> decltype(*x==y)
 
template<class T , class U >
auto operator!= (const T &x, const expected< U > &y) -> decltype(x==*y)
 
template<class T >
bool operator!= (const expected< T > &x, const error &y)
 
template<class T >
bool operator!= (const error &x, const expected< T > &y)
 
template<class T , class Enum >
std::enable_if_t< is_error_code_enum_v< Enum >, bool > operator!= (const expected< T > &x, Enum y)
 
template<class T , class Enum >
std::enable_if_t< is_error_code_enum_v< Enum >, bool > operator!= (Enum x, const expected< T > &y)
 
bool operator== (const expected< void > &x, const expected< void > &y)
 
bool operator!= (const expected< void > &x, const expected< void > &y)
 

Detailed Description

template<class T>
class caf::expected< T >

Represents the result of a computation which can either complete successfully with an instance of type T or fail with an error.

Template Parameters
TThe type of the result.

Member Function Documentation

◆ cerror()

template<class T >
const caf::error & caf::expected< T >::cerror ( ) const
noexcept

Returns the contained error.

Precondition
has_value() == false.

◆ cvalue()

template<class T >
const T & caf::expected< T >::cvalue ( ) const
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ error() [1/4]

template<class T >
caf::error && caf::expected< T >::error ( ) &&
noexcept

Returns the contained error.

Precondition
has_value() == false.

◆ error() [2/4]

template<class T >
caf::error & caf::expected< T >::error ( ) &
noexcept

Returns the contained error.

Precondition
has_value() == false.

◆ error() [3/4]

template<class T >
const caf::error && caf::expected< T >::error ( ) const &&
noexcept

Returns the contained error.

Precondition
has_value() == false.

◆ error() [4/4]

template<class T >
const caf::error & caf::expected< T >::error ( ) const &
noexcept

Returns the contained error.

Precondition
has_value() == false.

◆ operator bool()

template<class T >
caf::expected< T >::operator bool ( ) const
explicitnoexcept

Returns true if the object holds a value (is engaged).

◆ operator*() [1/4]

template<class T >
T && caf::expected< T >::operator* ( ) &&
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ operator*() [2/4]

template<class T >
T & caf::expected< T >::operator* ( ) &
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ operator*() [3/4]

template<class T >
const T && caf::expected< T >::operator* ( ) const &&
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ operator*() [4/4]

template<class T >
const T & caf::expected< T >::operator* ( ) const &
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ operator->() [1/2]

template<class T >
const T * caf::expected< T >::operator-> ( ) const
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ operator->() [2/2]

template<class T >
T * caf::expected< T >::operator-> ( )
noexcept

Returns the contained value.

Precondition
has_value() == true.

◆ value() [1/4]

template<class T >
T & caf::expected< T >::value ( ) &

Returns the contained value.

Precondition
has_value() == true.

◆ value() [2/4]

template<class T >
T && caf::expected< T >::value ( ) &&

Returns the contained value.

Precondition
has_value() == true.

◆ value() [3/4]

template<class T >
const T & caf::expected< T >::value ( ) const &

Returns the contained value.

Precondition
has_value() == true.

◆ value() [4/4]

template<class T >
const T && caf::expected< T >::value ( ) const &&

Returns the contained value.

Precondition
has_value() == true.

Member Data Documentation

◆ nothrow_copy

template<class T >
constexpr bool caf::expected< T >::nothrow_copy
staticconstexpr
Initial value:
= std::is_nothrow_copy_constructible_v<T>
&& std::is_nothrow_copy_assignable_v<T>

Stores whether copy construct and copy assign never throw.

◆ nothrow_move

template<class T >
constexpr bool caf::expected< T >::nothrow_move
staticconstexpr
Initial value:
= std::is_nothrow_move_constructible_v<T>
&& std::is_nothrow_move_assignable_v<T>

Stores whether move construct and move assign never throw.


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