diff options
Diffstat (limited to 'include/cru/common/Guard.h')
| -rw-r--r-- | include/cru/common/Guard.h | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/include/cru/common/Guard.h b/include/cru/common/Guard.h deleted file mode 100644 index 5a9f9c5d..00000000 --- a/include/cru/common/Guard.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include <functional> - -namespace cru { -struct Guard { - using ExitFunc = std::function<void()>; - - Guard() = default; - explicit Guard(const ExitFunc& f) : on_exit(f) {} - explicit Guard(ExitFunc&& f) : on_exit(std::move(f)) {} - Guard(const Guard&) = delete; - Guard(Guard&&) = default; - Guard& operator=(const Guard&) = delete; - Guard& operator=(Guard&&) = default; - ~Guard() { - if (on_exit) { - on_exit(); - } - } - - void Drop() { on_exit = {}; } - - ExitFunc on_exit; -}; -} // namespace cru |
