beman::optional::optional::or_else

Returns an optional containing the contained value if it has one, or the result of calling f if it does not.

Synopsis

Declared in <beman/optional/optional.hpp>

template<class F>
constexpr
optional<T>
or_else(F&& f) &&
requires (std::invocable<F> && std::move_constructible<T>);

Return Value

  • auto
  • optional<T>

Template Parameters

NameDescription
FAn invocable type returning an optional.

Parameters

NameDescription
fThe invocable to call if the optional is disengaged.