bsl::optional::optional

Constructors

Synopses

Declared in <bslstl_optional.h>

Create a disengaged optional object. Use the currently installed default allocator to supply memory. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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() converted to t_TYPE otherwise. Use the currently installed default allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is implicit only when an lvalue of const t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator-aware.

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. Use the currently installed default allocator to supply memory. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

constexpr
optional(bsl::nullopt_t) 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 and converted to t_TYPE otherwise. Use the allocator from original to supply memory if t_ANY_TYPE is a non-const version of t_TYPE; otherwise, use the currently installed default allocator. original is left in a valid but unspecified state. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an xvalue of t_ANY_TYPE, and is implicit only when an xvalue of t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator-aware.

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() converted to t_TYPE otherwise. Use the currently installed default allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is implicit only when an lvalue of const t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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() converted to t_TYPE otherwise. Use the currently installed default allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is explicit only when an lvalue of const t_ANY_TYPE is not implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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. Use the currently installed default allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from t_ANY_TYPE and is implicit only when t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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. Use the currently installed default allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from t_ANY_TYPE and is explicit only when t_ANY_TYPE is not implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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() converted to t_TYPE otherwise. Use the currently installed default allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an xvalue of t_ANY_TYPE, and is implicit only when an xvalue of t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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. Use the currently installed default allocator to supply memory.

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

Create a disengaged optional object. Use the specified allocator to supply memory.

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

Create an optional object having the value of the (template parameter) t_TYPE created in place using the specified args. Use the currently installed default allocator to supply memory. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

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

Create a disengaged optional object. Use the specified allocator to supply memory.

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

If the specified original contains a value, create an optional object whose contained value is initialized from *original; otherwise, create a disengaged optional object. Use the specified allocator to supply memory.

optional(
    std::allocator_arg_t,
    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 value; otherwise, create a disengaged optional object. Use the specified allocator to supply memory. original is left in a valid, but unspecified state. Note that this constructor does not participate in overload resolution unless optional is an accessible base class of t_DERIVED or t_DERIVED is optional itself (in which case the instantiation provides the allocator-extended move constructor).

template<class t_DERIVED>
optional(
    std::allocator_arg_t,
    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 and converted to t_TYPE otherwise. Use the specified allocator to supply memory. original is left in a valid but unspecified state. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an xvalue of t_ANY_TYPE, and is implicit only when an xvalue of t_ANY_TYPE is implicitly convertible to t_TYPE.

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t,
    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,
    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() converted to t_TYPE otherwise. Use the specified allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is implicit only when an lvalue of const t_ANY_TYPE is implicitly convertible to t_TYPE.

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t,
    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,
    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() converted to t_TYPE otherwise. Use the specified allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is implicit only when an lvalue of const t_ANY_TYPE is implicitly convertible to t_TYPE.

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t,
    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,
    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. Use the specified allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from t_ANY_TYPE, and is implicit only when t_ANY_TYPE is implicitly convertible to t_TYPE.

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

Create an optional object whose contained value is initialized by forwarding from the specified value. Use the specified allocator to supply memory. Note that this constructor participates in overload resolution only when t_TYPE is constructible from t_ANY_TYPE, and is explicit only when t_ANY_TYPE is not implicitly convertible to t_TYPE.

template<class t_ANY_TYPE = t_TYPE>
explicit
optional(
    std::allocator_arg_t,
    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 and converted to t_TYPE otherwise. Use the specified allocator to supply memory. original is left in a valid but unspecified state. Note that this constructor participates in overload resolution only when t_TYPE is constructible from an xvalue of t_ANY_TYPE, and is implicit only when an xvalue of t_ANY_TYPE is implicitly convertible to t_TYPE.

template<class t_ANY_TYPE>
optional(
    std::allocator_arg_t,
    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,
    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. Use the currently installed default allocator to supply memory. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

template<
    class t_INIT_LIST_TYPE,
    class... t_ARGS>
constexpr
explicit
optional(
    std::in_place_t,
    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. Use the specified allocator to supply memory.

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

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

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