[#bsl-optional-072-or_else-03]
= xref:bsl.adoc[bsl]::xref:bsl/optional-072.adoc[optional]::or&lowbar;else
:relfileprefix: ../../
:mrdocs:

Return this optional if engaged&semi; otherwise invoke `func`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;optional&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;FUNC&gt;
constexpr
xref:bsl/optional-072.adoc[optional&lt;t&lowbar;TYPE&gt;]
or&lowbar;else(t&lowbar;FUNC&& func) &amp;&amp;
requires conjunction&lowbar;v&lt;std&colon;&colon;is&lowbar;invocable&lt;t&lowbar;FUNC&gt;,
                              std&colon;&colon;is&lowbar;move&lowbar;constructible&lt;t&lowbar;TYPE&gt;&gt;;
----

== Description

If this object does not contain a value, invoke the specified `func` and return the result of that invocation&semi; otherwise, return a move&hyphen;constructed value from this object, leaving this object in an unspecified but valid state&period; Note that `func` must return `bsl&colon;&colon;optional`&period; Also note that the optional object returned by `func` is returned as&hyphen;is, without copying or moving&period;

== Return Value

this optional if engaged, otherwise the result of `func`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *func*
| callable invoked with the contained value or when empty
|===


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