[#BloombergLP-bdlb-ScopeExit-0e-2constructor-05]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/ScopeExit-0e.adoc[ScopeExit]::ScopeExit
:relfileprefix: ../../../
:mrdocs:

Create a `ScopeExit` that will invoke `function` on destruction&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
explicit
ScopeExit(void(* function)());
----

== Description

Create a `ScopeExit` object, which, upon its destruction will invoke the specified `function` unless the `release` method was called&period; If `function` is copied into the `EXIT&lowbar;FUNC` member, and that copy throws an exception, invoke `function` and rethrow the exception&period; The behavior is undefined if `function` or the member instance of `EXIT&lowbar;FUNC` throws an exception upon invocation&period; Note that this separate constructor for function pointers exists because without it the forwarding logic in the templated constructor implementation generates warnings about meaningless types generated&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *function*
| function pointer invoked on destruction unless `release` is called
|===


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