Constructors

Synopses

Declared in <bslstl_variant.h>

Create a variant object holding the 0th alternative, which is value‐initialized. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. This constructor participates in overload resolution only if the 0th alternative is default constructible. For simplicity of implementation, this method differs from the standard in the following ways: * constexpr is not implemented * noexcept specification is not implemented

template<class t_FIRST_ALT = t_HEAD>
requires std::is_default_constructible<t_FIRST_ALT>::value
variant();

Create a variant object holding the same alternative (if any) as the specified original object. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. If the original object is not valueless by exception', the contained value is copy‐constructed from the contained value of original. This constructor is deleted unless all alternatives are copy constructible. For simplicity of implementation, this method differs from the standard in the following ways: * conditional triviality is not implemented * constexpr is not implemented * noexcept specification is not implemented

variant(variant const& original) = default;

Create a variant object holding the same alternative (if any) held by the specified original. If this variant is allocator‐aware, the allocator of original is used to supply memory. If original is not valueless by exception, the contained value is move‐constructed from the contained value of original. This constructor participates in overload resolution only if all alternatives are move constructible. For simplicity of implementation, this method differs from the standard in the following ways: * conditional triviality is not implemented * constexpr is not implemented * noexcept specification is not implemented

variant(variant&& original) = default;

Create a variant object holding the same alternative (if any) held by the specified original. If this variant is allocator‐aware, the specified allocator is used to supply memory. If original is not valueless by exception, the contained value is copy/move‐constructed from the contained value of original. This constructor participates in overload resolution only if all alternatives are copy/move‐constructible.

template<class t_STD_VARIANT>
explicit
variant(t_STD_VARIANT&& original);

Create a variant object whose contained value is direct‐initialized from the specified t. The alternative selected is the best match among all alternatives for which the expression t_ALT_TYPE x[]= {std::forward<t_TYPE>(t)}; is well formed, and this constructor participates in overload resolution only if there is a unique best matching alternative and that alternative is constructible from t. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. Note that the cv‐qualification of an alternative type does not affect how well the alternative type matches an argument type. For simplicity of implementation, this method differs from the standard in the following ways: * constexpr is not implemented * noexcept specification is not implemented

template<class t_TYPE>
variant(t_TYPE&& t);

Create a variant object holding the 0th alternative, which is value‐initialized. If this variant is allocator‐aware, the specified allocator is used to supply memory. This constructor participates in overload resolution only if the 0th alternative is default constructible.

template<class t_FIRST = t_HEAD>
requires std::is_default_constructible<t_FIRST>::value
variant(
    std::allocator_arg_t,
    allocator_type allocator);

Create a variant object holding the alternative with index (template parameter) t_INDEX, direct‐initialized from the specified args. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. This constructor participates in overload resolution only if t_INDEX is a valid alternative index and the designated alternative is constructible from args. For simplicity of implementation, this method differs from the standard in the following ways: * constexpr is not implemented

template<
    std::size_t t_INDEX,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        t_ARGS...>::value
explicit
variant(
    bsl::in_place_index_t<t_INDEX>,
    t_ARGS&&... args);

Create a variant object holding a contained value of type (template parameter) t_TYPE, direct‐initialized from the specified args. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. This constructor participates in overload resolutionly if t_TYPE designates a unique alternative and is constructible from args. For simplicity of implementation, this method differs from the standard in the following way: * constexpr is not implemented

template<
    class t_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE, t_ARGS...>::value
explicit
variant(
    bsl::in_place_type_t<t_TYPE>,
    t_ARGS&&... args);

Create a variant object holding the same alternative (if any) as the specified original object. If this variant is allocator‐aware, the specified allocator is used to supply memory. If the original object is not valueless by exception`, the contained value is copy‐constructed from the contained value of original. This constructor is deleted unless all alternatives are copy constructible.

template<class t_FIRST = t_HEAD>
requires BloombergLP::bslstl::
                Variant_IsCopyConstructibleAll<t_FIRST, t_TAIL...>::value
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    variant const& original);

Create a variant object holding the same alternative (if any) held by the specified original. If this variant is allocator‐aware, the specified allocator is used to supply memory. If original is not valueless by exception, the contained value is copy/move‐constructed from the contained value of original. This constructor participates in overload resolution only if all alternatives are copy/move‐constructible.

template<class t_STD_VARIANT>
explicit
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    t_STD_VARIANT&& original);

Create a variant object whose contained value is direct‐initialized from the specified t. The alternative selected is the best match among all alternatives for which the expression t_ALT_TYPE x[]= {std::forward<t_TYPE>(t)}; is well formed, and this constructor participates in overload resolution only if there is a unique best matching alternative and that alternative is constructible from t. If this variant is allocator‐aware, the specified allocator is used to supply memory. Note that the cv‐qualification of an alternative type does not affect how well the alternative type matches an argument type.

template<class t_TYPE>
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    t_TYPE&& t);

Create a variant object holding the same alternative (if any) held by the specified original. If this variant is allocator‐aware, the specified allocator is used to supply memory. If original is not valueless by exception, the contained value is move‐constructed from the contained value of original. This constructor participates in overload resolution only if all alternatives are move constructible.

template<class t_FIRST = t_HEAD>
requires BloombergLP::bslstl::
                Variant_IsMoveConstructibleAll<t_FIRST, t_TAIL...>::value
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    variant&& original);

Create a variant object holding the alternative with index (template parameter) t_INDEX, direct‐initialized from the specified il and args. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. This constructor participates in overload resolution only if t_INDEX is a valid alternative index and the designated alternative is constructible from il and args. For simplicity of implementation, this method differs from the standard in the following way: * constexpr is not implemented

template<
    std::size_t t_INDEX,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    bsl::in_place_index_t<t_INDEX>,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);

Create a variant object holding a contained value of type (template parameter) t_TYPE, direct‐initialized from the specified il and args. If this variant is allocator‐aware, the currently installed default allocator is used to supply memory. This constructor participates in overload resolution only if t_TYPE designates a unique alternative and is constructible from il and args.

template<
    class t_TYPE,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE,
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    bsl::in_place_type_t<t_TYPE>,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);

Create a variant object holding the alternative with index (template parameter) t_INDEX, direct‐initialized from the specified args. If this variant is allocator‐aware, the specified allocator is used to supply memory. This constructor participates in overload resolution only if t_INDEX is a valid alternative index and the designated alternative is constructible from args.

template<
    std::size_t t_INDEX,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    bsl::in_place_index_t<t_INDEX>,
    t_ARGS&&... args);

Create a variant object holding a contained value of type (template parameter) t_TYPE, direct‐initialized from the specified args. If this variant is allocator‐aware, the specified allocator `is used to supply memory. This constructor participates in overload resolutionly if `t_TYPE designates a unique alternative and is constructible from args.

template<
    class t_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE, t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    bsl::in_place_type_t<t_TYPE>,
    t_ARGS&&... args);

Create a variant object holding the alternative with index (template parameter) t_INDEX, direct‐initialized from the specified il and args. If this variant is allocator‐aware, the specified allocator is used to supply memory. This constructor participates in overload resolution only if t_INDEX is a valid alternative index and the designated alternative is constructible from il and args.

template<
    std::size_t t_INDEX,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires (t_INDEX < 1 + sizeof...(t_TAIL)) &&
                  std::is_constructible<BSLSTL_VARIANT_TYPE_AT_INDEX(t_INDEX),
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    bsl::in_place_index_t<t_INDEX>,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);

Create a variant object holding a contained value of type (template parameter) t_TYPE, direct‐initialized from the specified il and args. If this variant is allocator‐aware, the specified `allocator `is used to supply memory. This constructor participates in overload resolutionly if t_TYPE designates a unique alternative and is constructible from il and args.

template<
    class t_TYPE,
    class INIT_LIST_TYPE,
    class... t_ARGS>
requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) &&
                  std::is_constructible<t_TYPE,
                                        std::initializer_list<INIT_LIST_TYPE>&,
                                        t_ARGS...>::value
explicit
variant(
    std::allocator_arg_t,
    allocator_type allocator,
    bsl::in_place_type_t<t_TYPE>,
    std::initializer_list<INIT_LIST_TYPE> il,
    t_ARGS&&... args);

Created with MrDocs