bsl::optional::or_else

Return this optional if engaged; otherwise invoke func.

Synopses

Declared in <bslstl_optional.h>

Return this optional if engaged; otherwise invoke func.

template<class t_FUNC>
constexpr
optional<t_TYPE>
or_else(t_FUNC&& func) const &
requires conjunction_v<std::is_invocable<t_FUNC>,
                              std::is_copy_constructible<t_TYPE>>;
» more...

Return this optional if engaged; otherwise invoke func.

template<class t_FUNC>
constexpr
optional<t_TYPE>
or_else(t_FUNC&& func) &&
requires conjunction_v<std::is_invocable<t_FUNC>,
                              std::is_move_constructible<t_TYPE>>;
» more...

Return Value

this optional if engaged, otherwise the result of func

Parameters

NameDescription
funccallable invoked with the contained value or when empty