Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
util::Result< M > Class Template Reference

#include <result.h>

Public Member Functions

 Result ()
 
 Result (T obj)
 
 Result (Error error)
 
 Result (Result &&)=default
 
 ~Result ()=default
 
bool has_value () const noexcept
 std::optional methods, so functions returning optional<T> can change to return Result<T> with minimal changes to existing code, and vice versa. More...
 
const Tvalue () const LIFETIMEBOUND
 
Tvalue () LIFETIMEBOUND
 
template<class U >
T value_or (U &&default_value) const &
 
template<class U >
T value_or (U &&default_value) &&
 
 operator bool () const noexcept
 
const Toperator-> () const LIFETIMEBOUND
 
const Toperator* () const LIFETIMEBOUND
 
Toperator-> () LIFETIMEBOUND
 
Toperator* () LIFETIMEBOUND
 

Private Types

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

Private Member Functions

 Result (const Result &)=delete
 Disallow copy constructor, require Result to be moved for efficiency. More...
 
Resultoperator= (const Result &)=delete
 Disallow operator= to avoid confusion in the future when the Result class gains support for richer error reporting, and callers should have ability to set a new result value without clearing existing error messages. More...
 
Resultoperator= (Result &&)=delete
 

Private Attributes

std::variant< bilingual_str, Tm_variant
 

Friends

template<typename FT >
bilingual_str ErrorString (const Result< FT > &result)
 

Detailed Description

template<class M>
class util::Result< M >

Definition at line 35 of file result.h.

Member Typedef Documentation

◆ T

template<class M >
using util::Result< M >::T = std::conditional_t<std::is_same_v<M, void>, std::monostate, M>
private

Definition at line 38 of file result.h.

Constructor & Destructor Documentation

◆ Result() [1/5]

template<class M >
util::Result< M >::Result ( const Result< M > &  )
privatedelete

Disallow copy constructor, require Result to be moved for efficiency.

◆ Result() [2/5]

template<class M >
util::Result< M >::Result ( )
inline

Definition at line 56 of file result.h.

◆ Result() [3/5]

template<class M >
util::Result< M >::Result ( T  obj)
inline

Definition at line 57 of file result.h.

◆ Result() [4/5]

template<class M >
util::Result< M >::Result ( Error  error)
inline

Definition at line 58 of file result.h.

◆ Result() [5/5]

template<class M >
util::Result< M >::Result ( Result< M > &&  )
default

◆ ~Result()

template<class M >
util::Result< M >::~Result ( )
default

Member Function Documentation

◆ has_value()

template<class M >
bool util::Result< M >::has_value ( ) const
inlinenoexcept

std::optional methods, so functions returning optional<T> can change to return Result<T> with minimal changes to existing code, and vice versa.

Definition at line 64 of file result.h.

Here is the caller graph for this function:

◆ operator bool()

template<class M >
util::Result< M >::operator bool ( ) const
inlineexplicitnoexcept

Definition at line 85 of file result.h.

◆ operator*() [1/2]

template<class M >
const T & util::Result< M >::operator* ( ) const
inline

Definition at line 87 of file result.h.

◆ operator*() [2/2]

template<class M >
T & util::Result< M >::operator* ( )
inline

Definition at line 89 of file result.h.

◆ operator->() [1/2]

template<class M >
const T * util::Result< M >::operator-> ( ) const
inline

Definition at line 86 of file result.h.

◆ operator->() [2/2]

template<class M >
T * util::Result< M >::operator-> ( )
inline

Definition at line 88 of file result.h.

◆ operator=() [1/2]

template<class M >
Result & util::Result< M >::operator= ( const Result< M > &  )
privatedelete

Disallow operator= to avoid confusion in the future when the Result class gains support for richer error reporting, and callers should have ability to set a new result value without clearing existing error messages.

◆ operator=() [2/2]

template<class M >
Result & util::Result< M >::operator= ( Result< M > &&  )
privatedelete

◆ value() [1/2]

template<class M >
const T & util::Result< M >::value ( ) const
inline

Definition at line 65 of file result.h.

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

◆ value() [2/2]

template<class M >
T & util::Result< M >::value ( )
inline

Definition at line 70 of file result.h.

Here is the call graph for this function:

◆ value_or() [1/2]

template<class M >
template<class U >
T util::Result< M >::value_or ( U &&  default_value) &&
inline

Definition at line 81 of file result.h.

◆ value_or() [2/2]

template<class M >
template<class U >
T util::Result< M >::value_or ( U &&  default_value) const &
inline

Definition at line 76 of file result.h.

Friends And Related Function Documentation

◆ ErrorString

template<class M >
template<typename FT >
bilingual_str ErrorString ( const Result< FT > &  result)
friend

Member Data Documentation

◆ m_variant

template<class M >
std::variant<bilingual_str, T> util::Result< M >::m_variant
private

Definition at line 40 of file result.h.


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