[#bsl-variant-2constructor-0e] = xref:bsl.adoc[bsl]::xref:bsl/variant.adoc[variant]::variant :relfileprefix: ../../ :mrdocs: 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_FIRST_ALT = t_HEAD> requires std::is_default_constructible<t_FIRST_ALT>::value xref:bsl/variant/2constructor-06.adoc[variant](); ---- [.small]#xref:bsl/variant/2constructor-06.adoc[_» more..._]# 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/variant/2constructor-034.adoc[variant](xref:bsl/variant.adoc[variant] const& original) = default; ---- [.small]#xref:bsl/variant/2constructor-034.adoc[_» more..._]# 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/variant/2constructor-07a.adoc[variant](xref:bsl/variant.adoc[variant]&& original) = default; ---- [.small]#xref:bsl/variant/2constructor-07a.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_STD_VARIANT> explicit xref:bsl/variant/2constructor-011.adoc[variant](t_STD_VARIANT&& original); ---- [.small]#xref:bsl/variant/2constructor-011.adoc[_» more..._]# 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_TYPE> xref:bsl/variant/2constructor-04.adoc[variant](t_TYPE&& t); ---- [.small]#xref:bsl/variant/2constructor-04.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_FIRST = t_HEAD> requires std::is_default_constructible<t_FIRST>::value xref:bsl/variant/2constructor-015.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator); ---- [.small]#xref:bsl/variant/2constructor-015.adoc[_» more..._]# 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:bsl/variant/2constructor-018.adoc[variant]( bsl::in_place_index_t<t_INDEX>, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-018.adoc[_» more..._]# 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_TYPE, class... t_ARGS> requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) && std::is_constructible<t_TYPE, t_ARGS...>::value explicit xref:bsl/variant/2constructor-0d1.adoc[variant]( bsl::in_place_type_t<t_TYPE>, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-0d1.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_FIRST = t_HEAD> requires BloombergLP::bslstl:: Variant_IsCopyConstructibleAll<t_FIRST, t_TAIL...>::value xref:bsl/variant/2constructor-0b.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, xref:bsl/variant.adoc[variant] const& original); ---- [.small]#xref:bsl/variant/2constructor-0b.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_STD_VARIANT> explicit xref:bsl/variant/2constructor-07b.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, t_STD_VARIANT&& original); ---- [.small]#xref:bsl/variant/2constructor-07b.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_TYPE> xref:bsl/variant/2constructor-030.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, t_TYPE&& t); ---- [.small]#xref:bsl/variant/2constructor-030.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_FIRST = t_HEAD> requires BloombergLP::bslstl:: Variant_IsMoveConstructibleAll<t_FIRST, t_TAIL...>::value xref:bsl/variant/2constructor-026.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, xref:bsl/variant.adoc[variant]&& original); ---- [.small]#xref:bsl/variant/2constructor-026.adoc[_» more..._]# 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 [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:bsl/variant/2constructor-09.adoc[variant]( bsl::in_place_index_t<t_INDEX>, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-09.adoc[_» more..._]# 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:bsl/variant/2constructor-033.adoc[variant]( bsl::in_place_type_t<t_TYPE>, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-033.adoc[_» more..._]# 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:bsl/variant/2constructor-07fa.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_index_t<t_INDEX>, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-07fa.adoc[_» more..._]# 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_TYPE, class... t_ARGS> requires BSLSTL_VARIANT_HAS_UNIQUE_TYPE(t_TYPE) && std::is_constructible<t_TYPE, t_ARGS...>::value explicit xref:bsl/variant/2constructor-0d0.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_type_t<t_TYPE>, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-0d0.adoc[_» more..._]# 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:bsl/variant/2constructor-07f8.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_index_t<t_INDEX>, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-07f8.adoc[_» more..._]# 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:bsl/variant/2constructor-02d.adoc[variant]( std::allocator_arg_t, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_type_t<t_TYPE>, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-02d.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#