20 #ifndef RIPPLE_BASICS_EXPECTED_H_INCLUDED
21 #define RIPPLE_BASICS_EXPECTED_H_INCLUDED
23 #include <ripple/basics/contract.h>
25 #include <boost/outcome.hpp>
57 if (!base::_has_value(std::forward<Impl>(
self)))
58 Throw<bad_expected_access>();
65 if (!base::_has_error(std::forward<Impl>(
self)))
66 Throw<bad_expected_access>();
73 if (!base::_has_exception(std::forward<Impl>(
self)))
74 Throw<bad_expected_access>();
113 return std::move(
val_);
119 return std::move(
val_);
127 template <
typename E, std::
size_t N>
131 template <
class T,
class E>
133 :
private boost::outcome_v2::result<T, E, detail::throw_policy>
135 using Base = boost::outcome_v2::result<T, E, detail::throw_policy>;
138 template <
typename U>
139 requires std::convertible_to<U, T> constexpr
Expected(U && r)
144 template <
typename U>
145 requires std::convertible_to<U, E> &&
153 return Base::has_value();
158 return Base::value();
163 return Base::value();
168 return Base::error();
173 return Base::error();
176 constexpr
explicit operator bool()
const
186 return this->value();
191 return this->value();
196 return &this->value();
201 return &this->value();
209 :
private boost::outcome_v2::result<void, E, detail::throw_policy>
211 using Base = boost::outcome_v2::result<void, E, detail::throw_policy>;
220 template <
typename U>
221 requires std::convertible_to<U, E> &&
229 return Base::error();
234 return Base::error();
237 constexpr
explicit operator bool()
const
239 return Base::has_value();
245 #endif // RIPPLE_BASICS_EXPECTED_H_INCLUDED