[#bsl-optional-072-and_then-06]
= xref:bsl.adoc[bsl]::xref:bsl/optional-072.adoc[optional]::and&lowbar;then
:relfileprefix: ../../
:mrdocs:

Invoke `func` on the contained value, or return an empty optional&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
auto
and&lowbar;then(t&lowbar;FUNC&& func) &amp;;
----

== Description

If this object contains a value, invoke the specified `func` with the contained value as an argument and return the result of that invocation&semi; otherwise, return an empty optional&period; Note that `func` must return a specialization of `bsl&colon;&colon;optional`&period; Also note that the return type of `func` does not have to be this object type&period; Also note that the optional object returned by `func` is returned as&hyphen;is, without copying or moving&period; Finally note that the default allocator is used for constructing the empty optional when `func` is not invoked&period;

== Return Value

result of `func` if engaged, otherwise an empty optional

== Parameters

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


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