[#BloombergLP-bdlb-ScopeExit-0e-2constructor-06] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/ScopeExit-0e.adoc[ScopeExit]::ScopeExit :relfileprefix: ../../../ :mrdocs: Create a `ScopeExit` object, which, upon its destruction will invoke the specified `function` (or functor) unless its `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. If `EXIT_FUNC_PARAM` cannot be move converted to `EXIT_FUNC` via no‐throw means (either because such conversion does not exist or it is not marked as non‐throwing), `function` will always be copied into the member. This constructor participates in overload resolution only if `EXIT_FUNC_PARAM` is neither `EXIT_FUNC` nor `bdlb::ScopeExit<EXIT_FUNC>` and `EXIT_FUNC_PARAM` is convertible to `EXIT_FUNC`. The behavior is undefined if `function` or the member instance of `EXIT_FUNC` throws an exception upon invocation. == Synopsis Declared in `<bdlb_scopeexit.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class EXIT_FUNC_PARAM> explicit ScopeExit( EXIT_FUNC_PARAM&& function, void* = 0) requires bsl::is_constructible< // Copy construct EXIT_FUNC, const typename MoveUtil::Decay<EXIT_FUNC_PARAM>::type& >::value || bsl::is_constructible< // Move construct EXIT_FUNC, bslmf::MovableRef<typename MoveUtil::Decay<EXIT_FUNC_PARAM>::type> >::value; ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#