[#bsl-optional-072-transform-00]
= xref:bsl.adoc[bsl]::xref:bsl/optional-072.adoc[optional]::transform
:relfileprefix: ../../
:mrdocs:

If this object contains a value, invoke the specified `func` with the contained value as an argument and return `optional&lt;U&gt;` that contains the result of that invocation, where `U` is the cv&hyphen;unqualified `func` return type, which can be different from `t&lowbar;TYPE`&semi; otherwise, return an empty `optional&lt;U&gt;`&period; Note that `func` must return an object type other than array, `bsl&colon;&colon;in&lowbar;place&lowbar;t` or `bsl&colon;&colon;nullopt`&period; Also note that there is no requirement that `U` is movable&period; Finally note that the returned optional uses the allocator of the object returned by `func`, or the default allocator if `func` is not invoked&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
transform(t&lowbar;FUNC&& func) &amp;;
----


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