Run a function on scope exit. More...
#include <OnScopeExit.hpp>
Public Member Functions | |
OnScopeExit (std::function< void()> function_) | |
Run the function on scope exit. More... | |
~OnScopeExit () | |
Run the scope exit function and destroy the OnScopeExit instance. More... | |
void | clear () |
Set to the function to NOP (cancels scheduled execution). More... | |
void | executeNow () |
Execute the function now and then clear it. More... | |
void | rest (std::function< void()> function_) |
Set to the function to a different function (cancels previously scheduled execution). More... | |
Run a function on scope exit.
This class should be used as a stack based instance. The template constructor takes a function pointer or lambda expression. This function is run when the scope within which the instance is defined exits.
This version of on-scope-exit cannot be moved, other than via C++17 guaranteed copy ellison.
|
inlineexplicit |
Run the function on scope exit.
|
inline |
Run the scope exit function and destroy the OnScopeExit instance.
|
inline |
Set to the function to NOP (cancels scheduled execution).
|
inline |
Execute the function now and then clear it.
|
inline |
Set to the function to a different function (cancels previously scheduled execution).