[#BloombergLP-bdlb-ScopeExitUtil-makeScopeExit]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/ScopeExitUtil.adoc[ScopeExitUtil]::makeScopeExit
:relfileprefix: ../../../
:mrdocs:

Return a `ScopeExit` guard that invokes `function` on destruction&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;scopeexit&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class EXIT&lowbar;FUNC&lowbar;PARAM&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
static
xref:BloombergLP/bdlb/ScopeExit-0e.adoc[ScopeExit&lt;bsl::decay&lt;EXIT&lowbar;FUNC&lowbar;PARAM&gt;::type&gt;]
makeScopeExit(EXIT&lowbar;FUNC&lowbar;PARAM&& function);
----

== Description

Return a `ScopeExit` guard that uses the specified `function` as its exit function, and has the decayed type of `function` (class type or or function pointer type) as its exit function member type&period;

== Return Value

`ScopeExit` guard that invokes `function` on destruction

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *function*
| exit function or functor for the returned guard
|===


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