Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
util::Expected< T, E > Class Template Reference

The util::Expected class provides a standard way for low-level functions to return either error values or result values. More...

#include <expected.h>

Public Member Functions

constexpr Expected ()
constexpr Expected (T v)
template<class Err>
constexpr Expected (Unexpected< Err > u)
constexpr bool has_value () const noexcept
constexpr operator bool () const noexcept
constexpr const Tvalue () const &LIFETIMEBOUND
constexpr Tvalue () &LIFETIMEBOUND
constexpr T && value () &&LIFETIMEBOUND
template<class U>
T value_or (U &&default_value) const &
template<class U>
T value_or (U &&default_value) &&
constexpr const Eerror () const &noexcept LIFETIMEBOUND
constexpr Eerror () &noexcept LIFETIMEBOUND
constexpr E && error () &&noexcept LIFETIMEBOUND
constexpr void swap (Expected &other) noexcept
constexpr Toperator* () &noexcept LIFETIMEBOUND
constexpr const Toperator* () const &noexcept LIFETIMEBOUND
constexpr T && operator* () &&noexcept LIFETIMEBOUND
constexpr Toperator-> () noexcept LIFETIMEBOUND
constexpr const Toperator-> () const noexcept LIFETIMEBOUND

Private Attributes

std::variant< T, Em_data

Detailed Description

template<class T, class E>
class util::Expected< T, E >

The util::Expected class provides a standard way for low-level functions to return either error values or result values.

It provides a smaller version of std::expected from C++23. Missing features can be added, if needed.

Definition at line 44 of file expected.h.

Constructor & Destructor Documentation

◆ Expected() [1/3]

template<class T, class E>
util::Expected< T, E >::Expected ( )
inlineconstexpr

Definition at line 50 of file expected.h.

◆ Expected() [2/3]

template<class T, class E>
util::Expected< T, E >::Expected ( T v)
inlineconstexpr

Definition at line 51 of file expected.h.

◆ Expected() [3/3]

template<class T, class E>
template<class Err>
util::Expected< T, E >::Expected ( Unexpected< Err > u)
inlineconstexpr

Definition at line 53 of file expected.h.

Member Function Documentation

◆ error() [1/3]

template<class T, class E>
E && util::Expected< T, E >::error ( ) &&
inlineconstexprnoexcept

Definition at line 89 of file expected.h.

Here is the caller graph for this function:

◆ error() [2/3]

template<class T, class E>
E & util::Expected< T, E >::error ( ) &
inlineconstexprnoexcept

Definition at line 88 of file expected.h.

◆ error() [3/3]

template<class T, class E>
const E & util::Expected< T, E >::error ( ) const &
inlineconstexprnoexcept

Definition at line 87 of file expected.h.

Here is the caller graph for this function:

◆ has_value()

template<class T, class E>
bool util::Expected< T, E >::has_value ( ) const
inlineconstexprnoexcept

Definition at line 57 of file expected.h.

Here is the caller graph for this function:

◆ operator bool()

template<class T, class E>
util::Expected< T, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Definition at line 58 of file expected.h.

◆ operator*() [1/3]

template<class T, class E>
T && util::Expected< T, E >::operator* ( ) &&
inlineconstexprnoexcept

Definition at line 95 of file expected.h.

◆ operator*() [2/3]

template<class T, class E>
T & util::Expected< T, E >::operator* ( ) &
inlineconstexprnoexcept

Definition at line 93 of file expected.h.

◆ operator*() [3/3]

template<class T, class E>
const T & util::Expected< T, E >::operator* ( ) const &
inlineconstexprnoexcept

Definition at line 94 of file expected.h.

◆ operator->() [1/2]

template<class T, class E>
const T * util::Expected< T, E >::operator-> ( ) const
inlineconstexprnoexcept

Definition at line 98 of file expected.h.

◆ operator->() [2/2]

template<class T, class E>
T * util::Expected< T, E >::operator-> ( )
inlineconstexprnoexcept

Definition at line 97 of file expected.h.

◆ swap()

template<class T, class E>
void util::Expected< T, E >::swap ( Expected< T, E > & other)
inlineconstexprnoexcept

Definition at line 91 of file expected.h.

Here is the caller graph for this function:

◆ value() [1/3]

template<class T, class E>
T && util::Expected< T, E >::value ( ) &&
inlineconstexpr

Definition at line 74 of file expected.h.

Here is the caller graph for this function:

◆ value() [2/3]

template<class T, class E>
T & util::Expected< T, E >::value ( ) &
inlineconstexpr

Definition at line 67 of file expected.h.

◆ value() [3/3]

template<class T, class E>
const T & util::Expected< T, E >::value ( ) const &
inlineconstexpr

Definition at line 60 of file expected.h.

Here is the caller graph for this function:

◆ value_or() [1/2]

template<class T, class E>
template<class U>
T util::Expected< T, E >::value_or ( U && default_value) &&
inline

Definition at line 82 of file expected.h.

◆ value_or() [2/2]

template<class T, class E>
template<class U>
T util::Expected< T, E >::value_or ( U && default_value) const &
inline

Definition at line 77 of file expected.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_data

template<class T, class E>
std::variant<T, E> util::Expected< T, E >::m_data
private

Definition at line 47 of file expected.h.


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