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

Constructs an optional from another optional of type U&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;, const U&gt; &amp;&amp; !std&colon;&colon;is&lowbar;same&lowbar;v&lt;std&colon;&colon;remove&lowbar;cv&lowbar;t&lt;T&gt;, optional&lt;U&gt;&gt; &amp;&amp;
              !std&colon;&colon;is&lowbar;same&lowbar;v&lt;T&amp;, U&gt; &amp;&amp; !detail&colon;&colon;reference&lowbar;constructs&lowbar;from&lowbar;temporary&lowbar;v&lt;T&amp;, const U&gt;)
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;const U, T &amp;&gt;)
optional(xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const&& rhs) noexcept(noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;constructible&lowbar;v&lt;T &amp;, const U&gt;));
----

== Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional&period; If `T&amp;` can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference&period;

== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *U*
| The type contained the right hand side optional&period;
|===

== Parameters

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


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