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

`and&lowbar;then` overloads

== Synopses

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

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;FUNC&gt;
constexpr
auto
xref:bsl/optional-072/and_then-06.adoc[and&lowbar;then](t&lowbar;FUNC&& func) &amp;;
----

[.small]#xref:bsl/optional-072/and_then-06.adoc[_» more&period;&period;&period;_]#

Invoke the specified `func` on the contained value and return its optional result as a const lvalue&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;FUNC&gt;
constexpr
auto
xref:bsl/optional-072/and_then-080.adoc[and&lowbar;then](t&lowbar;FUNC&& func) const &amp;;
----

[.small]#xref:bsl/optional-072/and_then-080.adoc[_» more&period;&period;&period;_]#

Invoke the specified `func` on the contained value and return its optional result as an rvalue&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;FUNC&gt;
constexpr
auto
xref:bsl/optional-072/and_then-09.adoc[and&lowbar;then](t&lowbar;FUNC&& func) &amp;&amp;;
----

[.small]#xref:bsl/optional-072/and_then-09.adoc[_» more&period;&period;&period;_]#

Invoke the specified `func` on the contained value and return its optional result as a const rvalue&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;FUNC&gt;
constexpr
auto
xref:bsl/optional-072/and_then-04.adoc[and&lowbar;then](t&lowbar;FUNC&& func) const &amp;&amp;;
----

[.small]#xref:bsl/optional-072/and_then-04.adoc[_» more&period;&period;&period;_]#


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