diff options
author | rtk0c <[email protected]> | 2022-06-30 21:38:53 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-06-30 21:38:53 -0700 |
commit | 7fe47a9d5b1727a61dc724523b530762f6d6ba19 (patch) | |
tree | e95be6e66db504ed06d00b72c579565bab873277 /core/src/Utils/ScopeGuard.hpp | |
parent | 2cf952088d375ac8b2f45b144462af0953436cff (diff) |
Restructure project
Diffstat (limited to 'core/src/Utils/ScopeGuard.hpp')
-rw-r--r-- | core/src/Utils/ScopeGuard.hpp | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/core/src/Utils/ScopeGuard.hpp b/core/src/Utils/ScopeGuard.hpp deleted file mode 100644 index 28ffd0b..0000000 --- a/core/src/Utils/ScopeGuard.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include "Utils/Macros.hpp" - -#include <utility> - -template <class TCleanupFunc> -class ScopeGuard -{ -private: - TCleanupFunc mFunc; - bool mDismissed = false; - -public: - /// Specifically left this implicit so that constructs like - /// \code - /// ScopeGuard sg = [&]() { res.Cleanup(); }; - /// \endcode - /// would work. It is highly discourage and unlikely that one would want to use ScopeGuard as a function - /// parameter, so the normal argument that implicit conversion are harmful doesn't really apply here. - ScopeGuard(TCleanupFunc func) - : mFunc{ std::move(func) } - { - } - - ~ScopeGuard() - { - if (!mDismissed) { - mFunc(); - } - } - - void Dismiss() noexcept - { - mDismissed = true; - } -}; - -#define DEFER ScopeGuard UNIQUE_NAME(scopeGuard) = [&]() |