template<typename F>
struct SC::Deferred< F >
Executes a function at end of current scope (in the spirit of Zig defer
keyword).
- Template Parameters
-
F | The lambda / function to execute |
Example:
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_DUP_HANDLE, FALSE, processId);
if (processHandle == nullptr)
{
return false;
}
[&]
{
CloseHandle(processHandle);
processHandle = nullptr;
});
deferDeleteProcessHandle.disarm()
Deferred< F > MakeDeferred(F &&f)
Creates a Deferred object holding a function that will be invoked at end of current scope.
Definition: Deferred.h:61