Bitcoin Core 30.99.0
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
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 T & value () const &LIFETIMEBOUND
 
constexpr T & value () &LIFETIMEBOUND
 
constexpr T && value () &&LIFETIMEBOUND
 
template<class U >
value_or (U &&default_value) const &
 
template<class U >
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 T & operator* () &noexcept LIFETIMEBOUND
 
constexpr const T & operator* () const &noexcept LIFETIMEBOUND
 
constexpr T && operator* () &&noexcept LIFETIMEBOUND
 
constexpr T * operator-> () noexcept LIFETIMEBOUND
 
constexpr const T * operator-> () 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 >
constexpr util::Expected< T, E >::Expected ( )
inlineconstexpr

Definition at line 50 of file expected.h.

◆ Expected() [2/3]

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

Definition at line 51 of file expected.h.

◆ Expected() [3/3]

template<class T , class E >
template<class Err >
constexpr 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 >
constexpr E && util::Expected< T, E >::error ( ) &&
inlineconstexprnoexcept

Definition at line 89 of file expected.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ error() [2/3]

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

Definition at line 88 of file expected.h.

◆ error() [3/3]

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

Definition at line 87 of file expected.h.

◆ has_value()

template<class T , class E >
constexpr 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 >
constexpr util::Expected< T, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Definition at line 58 of file expected.h.

Here is the call graph for this function:

◆ operator*() [1/3]

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

Definition at line 95 of file expected.h.

Here is the call graph for this function:

◆ operator*() [2/3]

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

Definition at line 93 of file expected.h.

Here is the call graph for this function:

◆ operator*() [3/3]

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

Definition at line 94 of file expected.h.

Here is the call graph for this function:

◆ operator->() [1/2]

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

Definition at line 98 of file expected.h.

Here is the call graph for this function:

◆ operator->() [2/2]

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

Definition at line 97 of file expected.h.

Here is the call graph for this function:

◆ swap()

template<class T , class E >
constexpr 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 >
constexpr T && util::Expected< T, E >::value ( ) &&
inlineconstexpr

Definition at line 74 of file expected.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ value() [2/3]

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

Definition at line 67 of file expected.h.

Here is the call graph for this function:

◆ value() [3/3]

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

Definition at line 60 of file expected.h.

Here is the call graph for this function:
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.

Here is the call graph for this function:

◆ 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 call graph for this function:
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: