ScopeExit is a general‐purpose scope proctor class template that is intended to be used as an automatic (stack) variable that calls an exit function upon its destruction (when its scope is exited).
Synopsis
Declared in <bdlb_scopeexit.h>
template<class EXIT_FUNC>
class [[nodiscard]] ScopeExit;
Description
The template argument EXIT_FUNC shall be a function object type, or a pointer to a function. If EXIT_FUNC is an object type, it shall satisfy the requirements of Destructible, Callable, and MoveConstructible as specified by the ISO C++ standard. Note that to fulfill the MoveConstructible constraint a type does not have to implement a move constructor. If it has a copy constructor, that will work fine as long at the move constructor is not deleted (or in case of C++03 emulated moves, private). The behavior is undefined if calling (the member instance of) EXIT_FUNC throws an exception (as it will be called from the destructor).
Member Functions
Name |
Description |
|
Constructors |
|
Destroy this object. Execute the exit function unless |
Turn off the execution of the exit function of this object on destruction. |
Deduction Guides
Name |
Description |
Deduce the template parameter |
Return Value
|
Note
|
The return value should not be discarded. |
Created with MrDocs