bsl::make_optional

Return an optional containing a value constructed from the arguments.

Synopsis

Declared in <bslstl_optional.h>

template<
    class t_TYPE,
    class t_INIT_LIST_TYPE,
    class... t_ARGS>
constexpr
bsl::optional<t_TYPE>
make_optional(
    std::initializer_list<t_INIT_LIST_TYPE> il,
    t_ARGS&&... args);

Description

Return an optional object containing a t_TYPE object created by invoking a bsl::optional in_place_t constructor with the specified il and args as the constructor arguments. If t_TYPE uses an allocator, the default allocator will be used for the optional object. This function can be called in constant expressions only if t_TYPE is not allocator-aware.

Return Value

optional containing a t_TYPE constructed from il and args

Parameters

NameDescription
ilinitializer list forwarded to construct the contained value
argsarguments forwarded to construct the contained value