C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Related Functions | 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
 

Public Member Functions

template<class U >
 expected (U x, typename std::enable_if< std::is_convertible< U, T >::value >::type *=nullptr)
 
 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)
 
template<class Enum , class = std::enable_if_t<is_error_code_enum_v<Enum>>>
 expected (Enum code)
 
 expected (expected &&other) noexcept(nothrow_move)
 
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< std::is_convertible< U, T >::value, expected & >::type 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)
 
T & value () noexcept
 Returns the contained value.
 
T & operator* () noexcept
 Returns the contained value.
 
T * operator-> () noexcept
 Returns the contained value.
 
caf::errorerror () noexcept
 Returns the contained error.
 
const T & cvalue () const noexcept
 Returns the contained value.
 
const T & value () const noexcept
 Returns the contained value.
 
const T & operator* () const noexcept
 Returns the contained value.
 
const T * operator-> () const noexcept
 Returns the contained value.
 
 operator bool () 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).
 
const caf::errorcerror () const noexcept
 Returns the contained error.
 
const caf::errorerror () const noexcept
 Returns the contained error.
 

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.
 

Related Functions

(Note that these are not member functions.)

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<typename 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<typename T >
const caf::error & caf::expected< T >::cerror ( ) const
noexcept

Returns the contained error.

Precondition
engaged() == false.

◆ cvalue()

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

Returns the contained value.

Precondition
engaged() == true.

◆ error() [1/2]

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

Returns the contained error.

Precondition
engaged() == false.

◆ error() [2/2]

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

Returns the contained error.

Precondition
engaged() == false.

◆ operator bool()

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

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

◆ operator*() [1/2]

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

Returns the contained value.

Precondition
engaged() == true.

◆ operator*() [2/2]

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

Returns the contained value.

Precondition
engaged() == true.

◆ operator->() [1/2]

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

Returns the contained value.

Precondition
engaged() == true.

◆ operator->() [2/2]

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

Returns the contained value.

Precondition
engaged() == true.

◆ value() [1/2]

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

Returns the contained value.

Precondition
engaged() == true.

◆ value() [2/2]

template<typename T >
T & caf::expected< T >::value ( )
noexcept

Returns the contained value.

Precondition
engaged() == true.

Member Data Documentation

◆ nothrow_copy

template<typename T >
constexpr bool caf::expected< T >::nothrow_copy
staticconstexpr
Initial value:
= std::is_nothrow_copy_constructible<T>::value
&& std::is_nothrow_copy_assignable<T>::value

Stores whether copy construct and copy assign never throw.

◆ nothrow_move

template<typename T >
constexpr bool caf::expected< T >::nothrow_move
staticconstexpr
Initial value:
= std::is_nothrow_move_constructible<T>::value
&& std::is_nothrow_move_assignable<T>::value

Stores whether move construct and move assign never throw.


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