[#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. == Synopsis Declared in `<bdlb_scopeexit.h>` [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. If `function` is copied into the `EXIT_FUNC` member, and that copy throws an exception, invoke `function` and rethrow the exception. The behavior is undefined if `function` or the member instance of `EXIT_FUNC` throws an exception upon invocation. 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. == Parameters [cols="1,4"] |=== | Name| Description | *function* | function pointer invoked on destruction unless `release` is called |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#