legate::ScopeFail#

template<typename F>
class ScopeFail#

Similar to ScopeGuard, except that the callable is only executed if the scope is exited due to an exception.

Template Parameters:

F – The type of the callable to execute.

Public Types

using value_type = F#

The type of callable stored within the ScopeFail.

Public Functions

explicit ScopeFail(value_type &&fn) noexcept#

Construct a ScopeFail.

On destruction, a ScopeFail will execute fn if and only if the scope is being exited due to an uncaught exception. Therefore, unlike ScopeGuard, it is not possible to “disable” a ScopeFail.

fn will be invoked with no arguments, and any return value discarded. fn must be no-throw move-constructible, and must not throw any exceptions when invoked.

See also

ScopeGuard

Parameters:

fn – The function to execute.

~ScopeFail() noexcept#

Destroy a ScopeFail.

If the ScopeFail is being destroyed due to the result of exception-related stack unwinding, then the held functor is executed, otherwise has no effect.