|
AGX Dynamics 2.41.1.2
|
Register a callback to be called at the end of the current scope. More...
#include <OnScopeExit.h>
Public Member Functions | |
| OnScopeExit (Callback &&callback) | |
| OnScopeExit (const OnScopeExit &)=delete | |
| OnScopeExit (OnScopeExit &&other) | |
| ~OnScopeExit () | |
| OnScopeExit & | operator= (const OnScopeExit &)=delete |
Register a callback to be called at the end of the current scope.
The callback may not throw exceptions, std::terminate may be called immediately if it does.
The callback should not take any parameters. The return value is ignored.
A factory function, onScopeExit, is provided to make OnScopeExit using lambdas possible.
Example usage:
void myFunction() { FILE* myFile = fopen(....); const auto& closeFile = onScopeExit([myFile]() { fclose(myFile); }); std::ignore = closeFile; std::ignore is used to prevent warning about unused variable.
The rest of the function goes here, possibly with early returns or exception throwing. }
Definition at line 53 of file OnScopeExit.h.
|
inline |
Definition at line 56 of file OnScopeExit.h.
|
inline |
Definition at line 61 of file OnScopeExit.h.
|
delete |
|
inline |
Definition at line 69 of file OnScopeExit.h.
References LOGGER_ENDL, and LOGGER_ERROR.
|
delete |