55 template<
typename U = T>
60 template<
typename... Args>
64 template<
typename U,
typename... Args>
67 : m_value(list,
util::forward<Args>(args)...) {}
76 template<
typename U = T>
79 m_value = util::forward<U>(
value);
83 constexpr auto operator->() {
return util::addressof(m_value.value()); }
84 constexpr auto operator->()
const {
return util::addressof(m_value.value()); }
86 constexpr auto operator*() & -> T& {
return m_value.value(); }
87 constexpr auto operator*() const& -> T const& {
return m_value.value(); }
88 constexpr auto operator*() && -> T&& {
return util::move(m_value).value(); }
89 constexpr auto operator*() const&& -> T const&& {
return util::move(m_value).value(); }
91 constexpr explicit operator bool()
const {
return true; }
92 constexpr auto has_value() const ->
bool {
return true; }
94 constexpr auto value() & -> T& {
return m_value.value(); }
95 constexpr auto value() const& -> T const& {
return m_value.value(); }
96 constexpr auto value() && -> T&& {
return util::move(m_value).value(); }
97 constexpr auto value() const&& -> T const&& {
return util::move(m_value).value(); }
99 constexpr void error() const& {}
102 template<concepts::ConvertibleTo<T> U>
108 template<concepts::ConvertibleTo<T> U>
111 return *util::move(*
this);
116 template<
typename... Args>
118 constexpr auto emplace(Args&&... args) -> T& {
119 return m_value.emplace(util::forward<Args>(args)...);
122 template<
typename U,
typename... Args>
124 constexpr auto emplace(std::initializer_list<U> list, Args&&... args) -> T& {
125 return m_value.emplace(list, util::forward<Args>(args)...);
133 template<
typename U,
typename G>
142 template<concepts::EqualityComparableWith<T> U,
typename G>
144 return b.has_value() && *a == *b;
149 constexpr friend auto operator==(
Expected const& a, U
const& b) ->
bool {
150 return a.value() == b;
158 template<concepts::RemoveCVRefSameAs<Expected> Self,
typename F,
159 typename U = meta::UnwrapRefDecay<meta::InvokeResult<F, meta::Like<Self, T>>>>
171 template<concepts::RemoveCVRefSameAs<Expected> Self,
typename F,
172 typename R = meta::InvokeResult<F, meta::Like<Self, T>>>
178 template<concepts::RemoveCVRefSameAs<Expected> Self,
typename F>
181 return util::forward<Self>(self);
184 template<concepts::RemoveCVRefSameAs<Expected> Self,
typename F>
187 return util::forward<Self>(self);
Definition monad_interface.h:15
Definition rebindable_box.h:42
Definition expected_forward_declaration.h:8
constexpr auto operator=(Expected &&) -> Expected &requires(concepts::MoveConstructible< T >)=default
constexpr friend auto tag_invoke(types::Tag< function::monad::fmap_right >, Self &&self, F &&) -> Expected
Definition expected_void_error.h:186
constexpr auto emplace(Args &&... args) -> T &
Definition expected_void_error.h:118
constexpr auto value() const &&-> T const &&
Definition expected_void_error.h:97
constexpr friend void tag_invoke(types::Tag< util::swap >, Expected &a, Expected &b)
Definition expected_void_error.h:136
friend class Expected
Definition expected_void_error.h:134
constexpr void error() &&
Definition expected_void_error.h:100
constexpr auto operator*() const &&-> T const &&
Definition expected_void_error.h:89
constexpr auto emplace(std::initializer_list< U > list, Args &&... args) -> T &
Definition expected_void_error.h:124
constexpr auto value() &&-> T &&
Definition expected_void_error.h:96
constexpr auto has_value() const -> bool
Definition expected_void_error.h:92
constexpr friend auto operator==(Expected const &, Unexpected< G > const &) -> bool
Definition expected_void_error.h:154
constexpr auto operator=(Expected const &) -> Expected &requires(concepts::CopyConstructible< T >)=default
constexpr auto operator*() const &-> T const &
Definition expected_void_error.h:87
constexpr friend auto operator==(Expected const &a, Expected< U, G > const &b) -> bool
Definition expected_void_error.h:143
constexpr auto operator*() &&-> T &&
Definition expected_void_error.h:88
constexpr Expected(Expected const &)=delete
constexpr auto value() &-> T &
Definition expected_void_error.h:94
constexpr Expected(types::InPlace, std::initializer_list< U > list, Args &&... args)
Definition expected_void_error.h:66
constexpr friend auto tag_invoke(types::Tag< function::monad::bind >, Self &&self, F &&function) -> R
Definition expected_void_error.h:174
constexpr auto optional_value() const
Definition expected_void_error.h:114
constexpr Expected()=default
void Error
Definition expected_void_error.h:29
constexpr void const & other
Definition expected_void_error.h:51
constexpr auto operator->() const
Definition expected_void_error.h:84
constexpr ~Expected()=default
constexpr auto operator->()
Definition expected_void_error.h:83
constexpr auto value_or(U &&) const &-> T
Definition expected_void_error.h:104
constexpr auto operator=(Expected const &) -> Expected &requires(!concepts::CopyConstructible< T >)=delete
constexpr void error() const &
Definition expected_void_error.h:99
constexpr Expected(Expected &&)=default
constexpr friend auto tag_invoke(types::Tag< function::monad::fmap >, Self &&self, F &&function) -> Expected< U, void >
Definition expected_void_error.h:160
constexpr auto operator*() &-> T &
Definition expected_void_error.h:86
constexpr auto __try_did_succeed() &&-> Expected
Definition expected_void_error.h:129
constexpr Expected(Expected const &)=default
T Value
Definition expected_void_error.h:28
constexpr Expected(types::InPlace, Args &&... args)
Definition expected_void_error.h:62
constexpr auto __try_move_out() &&-> T &&
Definition expected_void_error.h:130
constexpr auto value() const &-> T const &
Definition expected_void_error.h:95
constexpr friend auto tag_invoke(types::Tag< function::monad::fail >, Self &&self, F &&) -> Expected
Definition expected_void_error.h:180
auto __try_did_fail() &&-> Expected
Definition expected_void_error.h:128
constexpr auto value_or(U &&) &&-> T
Definition expected_void_error.h:110
Definition optional_forward_declaration.h:5
Definition unexpected.h:14
Definition operations.h:11
Definition operations.h:99
Definition operations.h:34
Definition operations.h:24
Definition operations.h:43
Definition expected_can_convert_constructor.h:9
constexpr auto invoke
Definition invoke.h:100
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
constexpr struct di::util::SwapFunction swap
void unreachable()
Definition unreachable.h:4
Expected(T &&) -> Expected< meta::UnwrapRefDecay< T >, void >
constexpr auto in_place
Definition in_place.h:8