Bitcoin Core 30.99.0
P2P Digital Currency
Public Member Functions | Private Types | 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 (ValueType v)
 
template<class Err >
constexpr Expected (Unexpected< Err > u)
 
constexpr bool has_value () const noexcept
 
constexpr operator bool () const noexcept
 
constexpr const ValueTypevalue () const LIFETIMEBOUND
 
constexpr ValueTypevalue () LIFETIMEBOUND
 
template<class U >
ValueType value_or (U &&default_value) const &
 
template<class U >
ValueType value_or (U &&default_value) &&
 
constexpr const Eerror () const LIFETIMEBOUND
 
constexpr Eerror () LIFETIMEBOUND
 
constexpr ValueTypeoperator* () LIFETIMEBOUND
 
constexpr const ValueTypeoperator* () const LIFETIMEBOUND
 
constexpr ValueTypeoperator-> () LIFETIMEBOUND
 
constexpr const ValueTypeoperator-> () const LIFETIMEBOUND
 

Private Types

using ValueType = std::conditional_t< std::is_same_v< T, void >, std::monostate, T >
 

Private Attributes

std::variant< ValueType, 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 33 of file expected.h.

Member Typedef Documentation

◆ ValueType

template<class T , class E >
using util::Expected< T, E >::ValueType = std::conditional_t<std::is_same_v<T, void>, std::monostate, T>
private

Definition at line 36 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 40 of file expected.h.

◆ Expected() [2/3]

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

Definition at line 41 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 43 of file expected.h.

Member Function Documentation

◆ error() [1/2]

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

Definition at line 72 of file expected.h.

Here is the call graph for this function:

◆ error() [2/2]

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

Definition at line 77 of file expected.h.

Here is the call graph for this function:

◆ has_value()

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

Definition at line 47 of file expected.h.

◆ operator bool()

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

Definition at line 48 of file expected.h.

◆ operator*() [1/2]

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

Definition at line 84 of file expected.h.

◆ operator*() [2/2]

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

Definition at line 83 of file expected.h.

◆ operator->() [1/2]

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

Definition at line 87 of file expected.h.

◆ operator->() [2/2]

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

Definition at line 86 of file expected.h.

◆ value() [1/2]

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

Definition at line 50 of file expected.h.

Here is the call graph for this function:

◆ value() [2/2]

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

Definition at line 55 of file expected.h.

Here is the call graph for this function:

◆ value_or() [1/2]

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

Definition at line 67 of file expected.h.

◆ value_or() [2/2]

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

Definition at line 62 of file expected.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_data

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

Definition at line 37 of file expected.h.


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