From 8f0dda5eab181b0f14f2652b4e984aaaae3f258c Mon Sep 17 00:00:00 2001 From: rtk0c Date: Mon, 27 Jun 2022 18:27:13 -0700 Subject: Start from a clean slate --- core/src/Utils/ScopeGuard.hpp | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 core/src/Utils/ScopeGuard.hpp (limited to 'core/src/Utils/ScopeGuard.hpp') 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 - -template -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) = [&]() -- cgit v1.2.3-70-g09d2