[#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 `&lt;bdlb&lowbar;scopeexit&period;h&gt;`

If `bsl&colon;&colon;is&lowbar;nothrow&lowbar;move&lowbar;constructible&lt;EXIT&lowbar;FUNC&gt;&colon;&colon;value` is `true` or `EXIT&lowbar;FUNC` is a move&hyphen;only type, move construct, otherwise, copy construct the exit function from the specified `original`&period; If construction succeeds, call `release()` on `original`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-07.adoc[ScopeExit](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;ScopeExit&gt;] original) noexcept(&sol;&ast; see-below &ast;&sol;);
----

[.small]#xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-07.adoc[_» more&period;&period;&period;_]#

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;


[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&period;&period;&period;_]#

Create a `ScopeExit` object, which, upon its destruction will invoke the specified `function` (or functor) unless its `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; If `EXIT&lowbar;FUNC&lowbar;PARAM` cannot be move converted to `EXIT&lowbar;FUNC` via no&hyphen;throw means (either because such conversion does not exist or it is not marked as non&hyphen;throwing), `function` will always be copied into the member&period; This constructor participates in overload resolution only if `EXIT&lowbar;FUNC&lowbar;PARAM` is neither `EXIT&lowbar;FUNC` nor `bdlb&colon;&colon;ScopeExit&lt;EXIT&lowbar;FUNC&gt;` and `EXIT&lowbar;FUNC&lowbar;PARAM` is convertible to `EXIT&lowbar;FUNC`&period; The behavior is undefined if `function` or the member instance of `EXIT&lowbar;FUNC` throws an exception upon invocation&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class EXIT&lowbar;FUNC&lowbar;PARAM&gt;
explicit
xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-06.adoc[ScopeExit](
    EXIT&lowbar;FUNC&lowbar;PARAM&& function,
    void* = 0)
requires bsl&colon;&colon;is&lowbar;constructible&lt;  &sol;&sol; Copy construct
            EXIT&lowbar;FUNC,
            const typename MoveUtil&colon;&colon;Decay&lt;EXIT&lowbar;FUNC&lowbar;PARAM&gt;&colon;&colon;type&amp;
        &gt;&colon;&colon;value                                                             &verbar;&verbar;
        bsl&colon;&colon;is&lowbar;constructible&lt;  &sol;&sol; Move construct
            EXIT&lowbar;FUNC,
            bslmf&colon;&colon;MovableRef&lt;typename MoveUtil&colon;&colon;Decay&lt;EXIT&lowbar;FUNC&lowbar;PARAM&gt;&colon;&colon;type&gt;
        &gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdlb/ScopeExit-0e/2constructor-06.adoc[_» more&period;&period;&period;_]#


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