[#beman-optional-optional-03-2constructor-026]
= xref:beman.adoc[beman]::xref:beman/optional.adoc[optional]::xref:beman/optional/optional-03.adoc[optional]::optional
:relfileprefix: ../../../
:mrdocs:

Constructors

== Synopses

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

Default constructs an empty optional&period;


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

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

Copy constructs the value from `rhs` if it has one&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-03/2constructor-06c.adoc[optional](xref:beman/optional/optional-03.adoc[optional] const& other)
requires std&colon;&colon;is&lowbar;copy&lowbar;constructible&lowbar;v&lt;T&gt; &amp;&amp; std&colon;&colon;is&lowbar;trivially&lowbar;copy&lowbar;constructible&lowbar;v&lt;T&gt; = default;
----

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

Copy constructs the value from `rhs` if it has one&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-03/2constructor-0c.adoc[optional](xref:beman/optional/optional-03.adoc[optional] const& rhs)
requires std&colon;&colon;is&lowbar;copy&lowbar;constructible&lowbar;v&lt;T&gt; &amp;&amp; (!std&colon;&colon;is&lowbar;trivially&lowbar;copy&lowbar;constructible&lowbar;v&lt;T&gt;);
----

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

Constructs the value from `rhs` if it has one&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class U&gt;
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;U, T&gt;)
xref:beman/optional/optional-03/2constructor-04a.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;] const& rhs)
requires (detail&colon;&colon;enable&lowbar;from&lowbar;other&lt;T, U, const U&amp;&gt;);
----

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

Move constructs the value from `rhs` if it has one&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-03/2constructor-05.adoc[optional](xref:beman/optional/optional-03.adoc[optional]&& other)
requires std&colon;&colon;is&lowbar;move&lowbar;constructible&lowbar;v&lt;T&gt; &amp;&amp; std&colon;&colon;is&lowbar;trivially&lowbar;move&lowbar;constructible&lowbar;v&lt;T&gt; = default;
----

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

Move constructs the value from `rhs` if it has one&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
xref:beman/optional/optional-03/2constructor-0b.adoc[optional](xref:beman/optional/optional-03.adoc[optional]&& rhs) noexcept(std&colon;&colon;is&lowbar;nothrow&lowbar;move&lowbar;constructible&lowbar;v&lt;T&gt;)
requires std&colon;&colon;is&lowbar;move&lowbar;constructible&lowbar;v&lt;T&gt; &amp;&amp; (!std&colon;&colon;is&lowbar;trivially&lowbar;move&lowbar;constructible&lowbar;v&lt;T&gt;);
----

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

Constructs the value from `rhs` if it has one&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class U&gt;
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;U, T&gt;)
xref:beman/optional/optional-03/2constructor-06e.adoc[optional](xref:beman/optional/optional-03.adoc[optional&lt;U&gt;]&& rhs)
requires (detail&colon;&colon;enable&lowbar;from&lowbar;other&lt;T, U, U &amp;&amp;&gt;);
----

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

Constructs an empty optional&period;


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

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

Constructs the value from `u,` forwarding it if necessary&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class U = T&gt;
constexpr
explicit(!std&colon;&colon;is&lowbar;convertible&lowbar;v&lt;U, T&gt;)
xref:beman/optional/optional-03/2constructor-00.adoc[optional](U&& u)
requires detail&colon;&colon;enable&lowbar;forward&lowbar;value&lt;T, U&gt;;
----

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

Constructs the value in&hyphen;place using the given arguments&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
constexpr
explicit
xref:beman/optional/optional-03/2constructor-02a.adoc[optional](
    xref:beman/optional/in_place_t.adoc[in&lowbar;place&lowbar;t],
    Args&period;&period;&period;&&&period;&period;&period; args)
requires std&colon;&colon;is&lowbar;constructible&lowbar;v&lt;T, Args&period;&period;&period;&gt;;
----

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

Constructs the value in&hyphen;place using the given arguments&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class U,
    class&period;&period;&period; Args&gt;
constexpr
explicit
xref:beman/optional/optional-03/2constructor-07.adoc[optional](
    xref:beman/optional/in_place_t.adoc[in&lowbar;place&lowbar;t],
    std::initializer&lowbar;list&lt;U&gt; il,
    Args&period;&period;&period;&&&period;&period;&period; args)
requires std&colon;&colon;is&lowbar;constructible&lowbar;v&lt;T, std&colon;&colon;initializer&lowbar;list&lt;U&gt;&amp;, Args&amp;&amp;&period;&period;&period;&gt;;
----

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


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