Constraints: F models invocable<>
and E models copy_constructible
.
Mandates: is_same_v<remove_cvref_t<invoke_result_t<F>>, expected>
is true.
Effects: Equivalent to:
if (*this) { return *this; } else { return invoke(std::forward<F>(f)(error())); }
1 template <class F> constexpr expected or_else(F&& f) &&;
Constraints: F models invocable<>
and E models move_constructable
Mandates: is_same_v<remove_cvref_t<invoke_result_t<F>>, expected>
is true.
Effects: Equivalent to:
if (*this) { return std::move(*this); } else { return invoke(std::forward<F>(f)(std::move(error()))); }
invoke(std::forward<F>(f)(error()))
or invoke(std::forward<F>(f)(std::move(error())))
mean in this case?template <class F> constexpr expected or_else(F&& f) const&;
Constraints: F models invocable<>
and E models copy_constructible
.
Effects: Equivalent to:
if (*this) { return *this; } else { return invoke(std::forward<F>(f)()); }
1 template <class F> constexpr expected or_else(F&& f) &&;
Constraints: F models invocable<>
and E models move_constructible
.
Effects: Equivalent to:
if (*this) { return std::move(*this); } else { return invoke(std::forward<F>(f)()); }
F
models invocable<>
and the expression invoke(std::forward<F>(f))
is used inside else-block (no parameter)F
models invocable<cv error_type ref>
and the expression invoke(std::forward<F>(f), error())
for l-value ref overlads or invoke(std::forward<F>(f), std::move(error()))
for r-value ref overloads.