llvm::transformOptional

Apply F to the contained value of O if present.

Synopsis

Declared in <llvm/ADT/STLForwardCompat.h>

template<
    typename Optional,
    typename Function,
    typename Value = llvm::remove_cvref_t<Optional>::value_type>
constexpr
std::optional<remove_cvref_t<std::invoke_result_t<Function, Value>>>
transformOptional(
    Optional&& O,
    Function&& F);

Return Value

An optional with the result of F, or std::nullopt if O is empty.

Parameters

NameDescription
OOptional value to transform.
FFunction applied to the contained value when present.