[#beman-optional-optional-06-emplace]
= xref:beman.adoc[beman]::xref:beman/optional.adoc[optional]::xref:beman/optional/optional-06.adoc[optional&lt;T&&gt;]::emplace
:relfileprefix: ../../../
:mrdocs:

Emplaces a new value in the optional, destroying the current one if the optional is engaged&period;

== Synopsis

Declared in `&lt;beman&sol;optional&sol;optional&period;hpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class U&gt;
requires (std&colon;&colon;is&lowbar;constructible&lowbar;v&lt;T&amp;, U&gt; &amp;&amp; !detail&colon;&colon;reference&lowbar;constructs&lowbar;from&lowbar;temporary&lowbar;v&lt;T&amp;, U&gt;)
constexpr
T&
emplace(U&& u) noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;constructible&lowbar;v&lt;T &amp;, U&gt;);
----

== Description

Constructs the contained value from `u` if it is convertible to `T&amp;`&period;

== Return Value

T&amp;

== Template Parameters

[cols="1,4"]
|===
|Name|Description

| *U*
| The type of the value to emplace&period;
|===

== Parameters

[cols="1,4"]
|===
|Name|Description

| *u*
| The value to emplace&period;
|===


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