std::experimental::scope_fail
| Defined in header <experimental/scope>
|
||
template< class EF >
class scope_fail;
|
(library fundamentals TS v3) | |
The class template scope_fail is a general-purpose scope guard intended to call its exit function when a scope is exited via an exception.
scope_fail is not CopyConstructible, CopyAssignable or MoveAssignable, however, it may be MoveConstructible if EF meets some requirements, which permits wrapping a scope_fail into another object.
A scope_fail may be either active, i.e. calls its exit function on destruction, or inactive, i.e. does nothing on destruction. A scope_fail is active after constructed from an exit function.
A scope_fail can become inactive by calling release() on it either manually or automatically (by the move constructor). An inactive scope_fail may also be obtained by initializing with another inactive scope_fail. Once a scope_fail is inactive, it cannot become active again.
A scope_fail effectively holds an EF and a bool flag indicating if it is active, alongwith a counter of uncaught exceptions used for detecting whether the destructor is called during stack unwinding.