5#ifndef BITCOIN_UTIL_EXPECTED_H
6#define BITCOIN_UTIL_EXPECTED_H
32template <
class T,
class E>
36 using ValueType = std::conditional_t<std::is_same_v<T, void>, std::monostate,
T>;
47 constexpr bool has_value() const noexcept {
return m_data.index() == 0; }
48 constexpr explicit operator bool() const noexcept {
return has_value(); }
53 return std::get<0>(m_data);
58 return std::get<0>(m_data);
64 return has_value() ? value() : std::forward<U>(default_value);
69 return has_value() ? std::move(value()) : std::forward<U>(default_value);
75 return std::get<1>(m_data);
80 return std::get<1>(m_data);
The util::Expected class provides a standard way for low-level functions to return either error value...
constexpr ValueType * operator->() LIFETIMEBOUND
constexpr const ValueType & operator*() const LIFETIMEBOUND
constexpr ValueType & value() LIFETIMEBOUND
std::conditional_t< std::is_same_v< T, void >, std::monostate, T > ValueType
constexpr const ValueType & value() const LIFETIMEBOUND
constexpr E & error() LIFETIMEBOUND
ValueType value_or(U &&default_value) &&
std::variant< ValueType, E > m_data
constexpr ValueType & operator*() LIFETIMEBOUND
constexpr const ValueType * operator->() const LIFETIMEBOUND
ValueType value_or(U &&default_value) const &
constexpr const E & error() const LIFETIMEBOUND
constexpr bool has_value() const noexcept
constexpr Expected(Unexpected< Err > u)
constexpr Expected(ValueType v)
The util::Unexpected class represents an unexpected value stored in util::Expected.
constexpr Unexpected(E e)
#define T(expected, seed, data)