Constructors

Synopses

Declared in <bslstl_optional.h>

Create a disengaged optional object.

constexpr
optional() noexcept;

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);

Construct an optional in‐place from the specified arguments.

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

Create a disengaged optional object.

constexpr
optional(bsl::nullopt_t nullopt) noexcept;

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);

Same as the preceding overload.

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

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);

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);

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);

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);

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);

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);

Create a disengaged optional object.

optional(
    std::allocator_arg_t allocatorArg,
    AllocType allocator);

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);

Create a disengaged optional object.

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

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

Parameters

Name

Description

original

source optional used to initialize this object

nullopt

disengaged‐optional tag; value is unused

value

value compared with or used to initialize the optional

allocatorArg

tag selecting the allocator‐extended constructor

allocator

allocator used to supply memory

inPlace

tag selecting in‐place construction of the contained

args

arguments forwarded to construct the contained value value

il

initializer list forwarded to construct the contained value

Created with MrDocs