Generic scopeguard to simplify RAII where cleanup is needed.
More...
#include <Workspace/Application/LanguageUtils/scopeguard.h>
template<typename Callable>
class CSIRO::Application::ScopeGuard< Callable >
See presentation by Andrei Alexandrescu here: https://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
◆ ScopeGuard() [1/4]
- Parameters
-
rollback | Callable to invoke when the guard is destroyed. |
Creates a ScopeGuard that invokes the specified Callable object when it is destroyed if it is active at the time of destruction. To deactivate it, invoke the dismiss() function.
- Note
- The rollback function must not throw an exception, or it will result in the application terminating due to problems with destructor unwinding. Handle all exceptions within the rollback function.
◆ ScopeGuard() [2/4]
◆ ScopeGuard() [3/4]
◆ ScopeGuard() [4/4]
◆ ~ScopeGuard()
◆ dismiss()
Indicate that we no longer wish to invoke the rollback function.
◆ operator=()