userver: utils::expected< S, E > Class Template Reference
Loading...
Searching...
No Matches
utils::expected< S, E > Class Template Reference

#include <userver/utils/expected.hpp>

Detailed Description

template<class S, class E>
class utils::expected< S, E >

For holding a value or an error.

Definition at line 53 of file expected.hpp.

Public Member Functions

 expected (const S &success)
 
 expected (S &&success)
 
 expected (const unexpected< E > &error)
 
 expected (unexpected< E > &&error)
 
template<class G , typename = std::enable_if_t<std::is_convertible_v<G, E>>>
 expected (const unexpected< G > &error)
 
template<class G , typename = std::enable_if_t<std::is_convertible_v<G, E>>>
 expected (unexpected< G > &&error)
 
bool has_value () const noexcept
 Check whether *this contains an expected value.
 
Svalue () &
 Return reference to the value or throws bad_expected_access if it's not available.
 
S value () &&
 Extracts the value or throws bad_expected_access if it's not available.
 
const Svalue () const &
 
Eerror ()
 Return reference to the error value or throws bad_expected_access if it's not available.
 
const Eerror () const
 

Constructor & Destructor Documentation

◆ expected() [1/6]

template<class S , class E >
utils::expected< S, E >::expected ( const S & success)

Definition at line 119 of file expected.hpp.

◆ expected() [2/6]

template<class S , class E >
utils::expected< S, E >::expected ( S && success)

Definition at line 122 of file expected.hpp.

◆ expected() [3/6]

template<class S , class E >
utils::expected< S, E >::expected ( const unexpected< E > & error)

Definition at line 125 of file expected.hpp.

◆ expected() [4/6]

template<class S , class E >
utils::expected< S, E >::expected ( unexpected< E > && error)

Definition at line 128 of file expected.hpp.

◆ expected() [5/6]

template<class S , class E >
template<class G , typename >
utils::expected< S, E >::expected ( const unexpected< G > & error)

Definition at line 133 of file expected.hpp.

◆ expected() [6/6]

template<class S , class E >
template<class G , typename >
utils::expected< S, E >::expected ( unexpected< G > && error)

Definition at line 138 of file expected.hpp.

Member Function Documentation

◆ error() [1/2]

template<class S , class E >
E & utils::expected< S, E >::error ( )

Return reference to the error value or throws bad_expected_access if it's not available.

Exceptions
utils::bad_expected_accessif success value is not available

Definition at line 172 of file expected.hpp.

◆ error() [2/2]

template<class S , class E >
const E & utils::expected< S, E >::error ( ) const

Definition at line 182 of file expected.hpp.

◆ has_value()

template<class S , class E >
bool utils::expected< S, E >::has_value ( ) const
noexcept

Check whether *this contains an expected value.

Definition at line 142 of file expected.hpp.

◆ value() [1/3]

template<class S , class E >
S & utils::expected< S, E >::value ( ) &

Return reference to the value or throws bad_expected_access if it's not available.

Exceptions
utils::bad_expected_accessif *this contain an unexpected value

Definition at line 147 of file expected.hpp.

◆ value() [2/3]

template<class S , class E >
S utils::expected< S, E >::value ( ) &&

Extracts the value or throws bad_expected_access if it's not available.

Exceptions
utils::bad_expected_accessif *this contain an unexpected value

Definition at line 157 of file expected.hpp.

◆ value() [3/3]

template<class S , class E >
const S & utils::expected< S, E >::value ( ) const &

Definition at line 162 of file expected.hpp.


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