[#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 a value‐initialized 0th alternative. [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 a copy of `original`'s alternative. [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 a moved copy of `original`'s alternative. [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 from a `std::variant` `original`. [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 initialized from `t`. [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 a value‐initialized 0th alternative using `allocator`. [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 allocatorArg, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator); ---- [.small]#xref:bsl/variant/2constructor-015.adoc[_» more..._]# Create a `variant` object holding the `t_INDEX` alternative 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-018.adoc[variant]( bsl::in_place_index_t<t_INDEX> inPlaceIndex, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-018.adoc[_» more..._]# Create a `variant` object holding a `t_TYPE` alternative 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-0d1.adoc[variant]( bsl::in_place_type_t<t_TYPE> inPlaceType, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-0d1.adoc[_» more..._]# Create a `variant` object holding a copy of `original`'s alternative using `allocator`. [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 allocatorArg, 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 from a `std::variant` `original` using `allocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_STD_VARIANT> explicit xref:bsl/variant/2constructor-07b.adoc[variant]( std::allocator_arg_t allocatorArg, 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 initialized from `t` using `allocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_TYPE> xref:bsl/variant/2constructor-030.adoc[variant]( std::allocator_arg_t allocatorArg, 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 a moved copy of `original`'s alternative using `allocator`. [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 allocatorArg, 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 `t_INDEX` alternative 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-09.adoc[variant]( bsl::in_place_index_t<t_INDEX> inPlaceIndex, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-09.adoc[_» more..._]# Create a `variant` object holding a `t_TYPE` alternative 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> inPlaceType, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-033.adoc[_» more..._]# Create a `variant` object holding the `t_INDEX` alternative from `args` using `allocator`. [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 allocatorArg, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_index_t<t_INDEX> inPlaceIndex, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-07fa.adoc[_» more..._]# Create a `variant` object holding a `t_TYPE` alternative from `args` using `allocator`. [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 allocatorArg, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_type_t<t_TYPE> inPlaceType, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-0d0.adoc[_» more..._]# Create a `variant` object holding the `t_INDEX` alternative from `il` and `args` using `allocator`. [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 allocatorArg, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_index_t<t_INDEX> inPlaceIndex, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-07f8.adoc[_» more..._]# Create a `variant` object holding a `t_TYPE` alternative from `il` and `args` using `allocator`. [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 allocatorArg, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, bsl::in_place_type_t<t_TYPE> inPlaceType, std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/2constructor-02d.adoc[_» more..._]# == Parameters [cols="1,4"] |=== | Name| Description | *original* | variant to copy | *t* | value used to initialize the selected alternative | *allocatorArg* | tag selecting the allocator‐extended overload | *allocator* | allocator used to supply memory | *inPlaceIndex* | tag selecting the `t_INDEX` alternative | *args* | arguments used to construct the selected alternative | *inPlaceType* | tag selecting the `t_TYPE` alternative | *il* | initializer list used to construct the selected alternative |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#