Public Member Functions | List of all members
OnScopeExit Class Referencefinal

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ OnScopeExit()

OnScopeExit ( std::function< void()>  function_)
inlineexplicit

Run the function on scope exit.

◆ ~OnScopeExit()

~OnScopeExit ( )
inline

Run the scope exit function and destroy the OnScopeExit instance.

Member Function Documentation

◆ clear()

void clear ( )
inline

Set to the function to NOP (cancels scheduled execution).

◆ executeNow()

void executeNow ( )
inline

Execute the function now and then clear it.

◆ rest()

void rest ( std::function< void()>  function_)
inline

Set to the function to a different function (cancels previously scheduled execution).


The documentation for this class was generated from the following file: