beman::optional::optional<T&>::or_else

Calls a function if the optional is empty.

Synopsis

Declared in <beman/optional/optional.hpp>

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

Description

The return type is the same as the return type of f, which must return an optional type.

Return Value

optional

Template Parameters

NameDescription
FThe type of the invocable

Parameters

NameDescription
fThe invocable to apply to the contained value