bsl::optional::optional

Constructors

Synopses

Declared in <bslstl_optional.h>

Create a disengaged optional object.

constexpr
optional() noexcept;
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value().

template<class t_ANY_TYPE>
constexpr
optional(optional<t_ANY_TYPE> const& original);
» more...

Construct an optional in-place from the specified arguments.

template<class t_ANY_TYPE>
constexpr
explicit
optional(optional<t_ANY_TYPE> const& original);
» more...

Create a disengaged optional object.

constexpr
optional(bsl::nullopt_t nullopt) noexcept;
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() moved.

template<class t_ANY_TYPE>
constexpr
optional(BloombergLP::bslmf::MovableRef_Deduced<optional<t_ANY_TYPE>> original);
» more...

Same as the preceding overload.

template<class t_ANY_TYPE>
constexpr
explicit
optional(BloombergLP::bslmf::MovableRef_Deduced<optional<t_ANY_TYPE>> original);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value().

template<class t_ANY_TYPE>
constexpr
optional(std::optional<t_ANY_TYPE> const& original);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value().

template<class t_ANY_TYPE>
constexpr
explicit
optional(std::optional<t_ANY_TYPE> const& original);
» more...

Create an optional object whose contained value is initialized by forwarding from the specified value.

template<class t_ANY_TYPE = t_TYPE>
constexpr
optional(t_ANY_TYPE&& value);
» more...

Create an optional object whose contained value is initialized by forwarding from the specified value.

template<class t_ANY_TYPE = t_TYPE>
constexpr
explicit
optional(t_ANY_TYPE&& value);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value().

template<class t_ANY_TYPE>
constexpr
optional(std::optional<t_ANY_TYPE>&& original);
» more...

Explicitly create an optional by moving from the specified std::optional original.

template<class t_ANY_TYPE>
constexpr
explicit
optional(std::optional<t_ANY_TYPE>&& original);
» more...

Create a disengaged optional object.

optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator);
» more...

Create an optional object having the value of the (template parameter) t_TYPE created in place using the specified args.

template<class... t_ARGS>
constexpr
explicit
optional(
    std::in_place_t inPlace,
    t_ARGS&&... args);
» more...

Create a disengaged optional object.

optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    bsl::nullopt_t nullopt);
» more...

If the specified original contains a value, create an optional object whose contained value is initialized from *original; otherwise, create a.

optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    optional const& original);
» more...

If the optional base class of the specified original holds a value, create an optional object whose contained value is initialized by moving from that.

template<class t_DERIVED>
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    BloombergLP::bslmf::MovableRef_Deduced<t_DERIVED> original);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() moved.

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    BloombergLP::bslmf::MovableRef_Deduced<optional<t_ANY_TYPE>> original);
» more...

Explicitly create an optional by moving from the specified original using the specified allocator.

template<class t_ANY_TYPE>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    BloombergLP::bslmf::MovableRef_Deduced<optional<t_ANY_TYPE>> original);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value().

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    optional<t_ANY_TYPE> const& original);
» more...

Explicitly create an optional from the specified original using the specified allocator.

template<class t_ANY_TYPE>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    optional<t_ANY_TYPE> const& original);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value().

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    std::optional<t_ANY_TYPE> const& original);
» more...

Explicitly create an optional from the specified std::optional original using the specified allocator.

template<class t_ANY_TYPE>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    std::optional<t_ANY_TYPE> const& original);
» more...

Create an optional object whose contained value is initialized by forwarding from the specified value.

template<class t_ANY_TYPE = t_TYPE>
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    t_ANY_TYPE&& value);
» more...

Create an optional object whose contained value is initialized by forwarding from the specified value.

template<class t_ANY_TYPE = t_TYPE>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    t_ANY_TYPE&& value);
» more...

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() moved.

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    std::optional<t_ANY_TYPE>&& original);
» more...

Explicitly create an optional by moving from the specified std::optional original using the specified allocator.

template<class t_ANY_TYPE>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    std::optional<t_ANY_TYPE>&& original);
» more...

Create an optional object having the value of the (template parameter) t_TYPE created in place using the specified il and specified args.

template<
    class t_INIT_LIST_TYPE,
    class... t_ARGS>
constexpr
explicit
optional(
    std::in_place_t inPlace,
    std::initializer_list<t_INIT_LIST_TYPE> il,
    t_ARGS&&... args);
» more...

Create an optional object having the value of the (template parameter) t_TYPE created in place using the specified args.

template<class... t_ARGS>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    std::in_place_t inPlace,
    t_ARGS&&... args);
» more...

Assign a new value to this optional.

template<
    class t_INIT_LIST_TYPE,
    class... t_ARGS>
explicit
optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator,
    std::in_place_t inPlace,
    std::initializer_list<t_INIT_LIST_TYPE> il,
    t_ARGS&&... args);
» more...

Parameters

NameDescription
originalsource optional used to initialize this object
nulloptdisengaged-optional tag; value is unused
valuevalue compared with or used to initialize the optional
allocatorArgtag selecting the allocator-extended constructor
allocatorallocator used to supply memory
inPlacetag selecting in-place construction of the contained
argsarguments forwarded to construct the contained value value
ilinitializer list forwarded to construct the contained value