[#bsl-variant-emplace-03] = xref:bsl.adoc[bsl]::xref:bsl/variant.adoc[variant]::emplace :relfileprefix: ../../ :mrdocs: `emplace` overloads == Synopses Declared in `<bslstl_variant.h>` Create an object of alternative (template parameter) `t_TYPE` in place, direct‐initialized from the specified `args`, destroying any previously contained value first. Return a reference to the newly created `t_TYPE` object. If `t_TYPE` is allocator‐aware, it uses the allocator specified upon the construction of this `variant` object to supply memory; passing an allocator argument to this method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error. If the constructor of `t_TYPE` exits via an exception, this object may be left in the valueless by exception state. This method participates in overload resolution only 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 t_TYPE& xref:bsl/variant/emplace-06.adoc[emplace](t_ARGS&&... args); ---- [.small]#xref:bsl/variant/emplace-06.adoc[_» more..._]# Create the alternative with index (template parameter) `t_INDEX` in place, direct‐initialized from the specified `args`, destroying any previously contained value first. Return a reference to the newly created contained value. If the alternative is allocator‐aware, it uses the allocator specified upon the construction of this `variant` object to supply memory; passing an allocator argument to this method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error. If the alternative constructor exits via an exception, this object may be left in the valueless by exception state. This method 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 way: * `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 variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...>>::type& xref:bsl/variant/emplace-02.adoc[emplace](t_ARGS&&... args); ---- [.small]#xref:bsl/variant/emplace-02.adoc[_» more..._]# Create an object of alternative (template parameter) `t_TYPE` in place, direct‐initialized from the specified `il` and `args`, destroying any previously contained value first. Return a reference to the newly created `t_TYPE` object. If `t_TYPE` is allocator‐aware, it uses the allocator specified upon the construction of this `variant` object to supply memory; passing an allocator argument to this method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error. If the constructor of `t_TYPE` exits via an exception, this object may be left in the valueless by exception state. This method participates in overload resolution only if `t_TYPE` designates a unique alternative and 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< 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 t_TYPE& xref:bsl/variant/emplace-04.adoc[emplace]( std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/emplace-04.adoc[_» more..._]# Create the alternative with index (template parameter) `t_INDEX` in place, direct‐initialized from the specified `il` and args', destroying any previously contained value first. Return a reference to the newly created contained value. If the alternative is allocator‐aware, it uses the allocator specified upon the construction of this `variant` object to supply memory; passing an allocator argument to this method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error. If the alternative constructor exits via an exception, this object may be left in the valueless by exception state. This method 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 variant_alternative<t_INDEX, variant<t_HEAD, t_TAIL...>>::type& xref:bsl/variant/emplace-01.adoc[emplace]( std::initializer_list<INIT_LIST_TYPE> il, t_ARGS&&... args); ---- [.small]#xref:bsl/variant/emplace-01.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#