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

Construct from a U

== 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; !(std&colon;&colon;is&lowbar;same&lowbar;v&lt;std&colon;&colon;remove&lowbar;cvref&lowbar;t&lt;U&gt;, in&lowbar;place&lowbar;t&gt;) &amp;&amp;
                  !(std&colon;&colon;is&lowbar;same&lowbar;v&lt;std&colon;&colon;remove&lowbar;cvref&lowbar;t&lt;U&gt;, optional&gt;) &amp;&amp;
                  !detail&colon;&colon;reference&lowbar;constructs&lowbar;from&lowbar;temporary&lowbar;v&lt;T&amp;, U&gt;)
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;U, T &amp;&gt;)
optional(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; If `T&amp;` can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *u*
| The value to construct from&period;
|===


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