A simple scope guard that invokes a cleanup callable upon destruction. More...
#include <utils.hpp>
Public Member Functions | |
| ScopeExit (F &&cleanup) | |
Constructs a scope guard that will invoke cleanup on destruction. More... | |
| ScopeExit (ScopeExit const &)=delete | |
| ScopeExit & | operator= (ScopeExit const &)=delete |
| ScopeExit (ScopeExit &&)=delete | |
| ScopeExit & | operator= (ScopeExit &&)=delete |
A simple scope guard that invokes a cleanup callable upon destruction.
Guarantees the cleanup action runs when the guard goes out of scope, regardless of how the scope is exited (normal return or exception). If the cleanup itself throws an exception, it is suppressed to avoid calling std::terminate.
Usage:
| F | A callable type invocable with no arguments. |
Definition at line 86 of file detail/utils.hpp.
|
inlineexplicit |
Constructs a scope guard that will invoke cleanup on destruction.
| cleanup | The cleanup callable to invoke on destruction |
Definition at line 97 of file detail/utils.hpp.