[#BloombergLP-bdlb-ScopeExit-0e-2constructor-0a] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/ScopeExit-0e.adoc[ScopeExit]::ScopeExit :relfileprefix: ../../../ :mrdocs: Constructors == Synopses Declared in `<bdlb_scopeexit.h>` If `bsl::is_nothrow_move_constructible<EXIT_FUNC>::value` is `true` or `EXIT_FUNC` is a move‐only type, move construct, otherwise, copy construct the exit function from the specified `original`. If construction succeeds, call `release()` on `original`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-07.adoc[ScopeExit](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef<ScopeExit>] original) noexcept(/* see-below */); ---- [.small]#xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-07.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-05.adoc[ScopeExit](void(* function)()); ---- [.small]#xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-05.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class EXIT_FUNC_PARAM> explicit xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-06.adoc[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]#xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-06.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#