[#bsl-variant-emplace-04]
= xref:bsl.adoc[bsl]::xref:bsl/variant.adoc[variant]::emplace
:relfileprefix: ../../
:mrdocs:

Create a `t&lowbar;TYPE` alternative in place from `il` and `args`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;variant&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;TYPE,
    class INIT&lowbar;LIST&lowbar;TYPE,
    class&period;&period;&period; t&lowbar;ARGS&gt;
requires BSLSTL&lowbar;VARIANT&lowbar;HAS&lowbar;UNIQUE&lowbar;TYPE(t&lowbar;TYPE) &amp;&amp;
                  std&colon;&colon;is&lowbar;constructible&lt;t&lowbar;TYPE,
                                        std&colon;&colon;initializer&lowbar;list&lt;INIT&lowbar;LIST&lowbar;TYPE&gt;&amp;,
                                        t&lowbar;ARGS&period;&period;&period;&gt;&colon;&colon;value
t&lowbar;TYPE&
emplace(
    std::initializer&lowbar;list&lt;INIT&lowbar;LIST&lowbar;TYPE&gt; il,
    t&lowbar;ARGS&&&period;&period;&period; args);
----

== Description

Create an object of alternative (template parameter) `t&lowbar;TYPE` in place, direct&hyphen;initialized from the specified `il` and `args`, destroying any previously contained value first&period; Return a reference to the newly created `t&lowbar;TYPE` object&period; If `t&lowbar;TYPE` is allocator&hyphen;aware, it uses the allocator specified upon the construction of this `variant` object to supply memory&semi; passing an allocator argument to this method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error&period; If the constructor of `t&lowbar;TYPE` exits via an exception, this object may be left in the valueless by exception state&period; This method participates in overload resolution only if `t&lowbar;TYPE` designates a unique alternative and is constructible from `il` and `args`&period; For simplicity of implementation, this method differs from the standard in the following way&colon; &ast; `constexpr` is not implemented

== Return Value

reference to the newly created `t&lowbar;TYPE` object

== Parameters

[cols="1,4"]
|===
| Name| Description
| *il*
| initializer list used to construct the `t&lowbar;TYPE` alternative
| *args*
| additional arguments used to construct the alternative
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
