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

Constructors

== Synopses

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

Default constructor&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-06/2constructor-070.adoc[optional]() noexcept = default;
----

[.small]#xref:beman/optional/optional-06/2constructor-070.adoc[_» more&period;&period;&period;_]#

Copy constructor&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-06/2constructor-0a3.adoc[optional](xref:beman/optional/optional-06.adoc[optional] const& rhs) noexcept = default;
----

[.small]#xref:beman/optional/optional-06/2constructor-0a3.adoc[_» more&period;&period;&period;_]#

Constructs an empty optional&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-06/2constructor-008.adoc[optional](xref:beman/optional/nullopt_t.adoc[nullopt&lowbar;t] value) noexcept;
----

[.small]#xref:beman/optional/optional-06/2constructor-008.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U


[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&amp;&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;, U&amp;&gt;)
constexpr
xref:beman/optional/optional-06/2constructor-0b4.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;]& rhs) = delete;
----

[.small]#xref:beman/optional/optional-06/2constructor-0b4.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U&period;


[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&amp;&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;, U&amp;&gt;)
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;U &amp;, T &amp;&gt;)
xref:beman/optional/optional-06/2constructor-0d.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;]& rhs) noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;constructible&lowbar;v&lt;T &amp;, U &amp;&gt;);
----

[.small]#xref:beman/optional/optional-06/2constructor-0d.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U


[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&amp;&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&amp;&gt;)
constexpr
xref:beman/optional/optional-06/2constructor-01.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const& rhs) = delete;
----

[.small]#xref:beman/optional/optional-06/2constructor-01.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U&period;


[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&amp;&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&amp;&gt;)
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;const U &amp;, T &amp;&gt;)
xref:beman/optional/optional-06/2constructor-0f8.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const& rhs) noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;constructible&lowbar;v&lt;T &amp;, const U &amp;&gt;);
----

[.small]#xref:beman/optional/optional-06/2constructor-0f8.adoc[_» more&period;&period;&period;_]#

Construct from a U


[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;)
xref:beman/optional/optional-06/2constructor-0f2.adoc[optional](U&& u) noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;constructible&lowbar;v&lt;T &amp;, U&gt;);
----

[.small]#xref:beman/optional/optional-06/2constructor-0f2.adoc[_» more&period;&period;&period;_]#

Constructs an optional from a U, but deletes the constructor if


[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
xref:beman/optional/optional-06/2constructor-073.adoc[optional](U&& u) = delete;
----

[.small]#xref:beman/optional/optional-06/2constructor-073.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U


[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;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;, U&gt;)
constexpr
xref:beman/optional/optional-06/2constructor-0a8.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;]&& rhs) = delete;
----

[.small]#xref:beman/optional/optional-06/2constructor-0a8.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U&period;


[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;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;, U&gt;)
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;U, T &amp;&gt;)
xref:beman/optional/optional-06/2constructor-00b.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;]&& rhs) noexcept(noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;constructible&lowbar;v&lt;T &amp;, U&gt;));
----

[.small]#xref:beman/optional/optional-06/2constructor-00b.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U


[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
xref:beman/optional/optional-06/2constructor-09.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const&& rhs) = delete;
----

[.small]#xref:beman/optional/optional-06/2constructor-09.adoc[_» more&period;&period;&period;_]#

Constructs an optional from another optional of type U&period;


[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;)
xref:beman/optional/optional-06/2constructor-0b3.adoc[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;));
----

[.small]#xref:beman/optional/optional-06/2constructor-0b3.adoc[_» more&period;&period;&period;_]#

In&hyphen;place constructor&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class Arg&gt;
requires (std&colon;&colon;is&lowbar;constructible&lowbar;v&lt;T&amp;, Arg&gt; &amp;&amp; !detail&colon;&colon;reference&lowbar;constructs&lowbar;from&lowbar;temporary&lowbar;v&lt;T&amp;, Arg&gt;)
constexpr
explicit
xref:beman/optional/optional-06/2constructor-04.adoc[optional](
    xref:beman/optional/in_place_t.adoc[in&lowbar;place&lowbar;t],
    Arg&& arg);
----

[.small]#xref:beman/optional/optional-06/2constructor-04.adoc[_» more&period;&period;&period;_]#


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