From 6a6717cdd3ca625b4055a38c0aacb284ca784369 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 28 Mar 2023 01:15:13 +0300 Subject: [PATCH] BAN: ScopeGuard can now be disabled (it wont call the function) --- BAN/include/BAN/ScopeGuard.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BAN/include/BAN/ScopeGuard.h b/BAN/include/BAN/ScopeGuard.h index d39c12bde9..185262913c 100644 --- a/BAN/include/BAN/ScopeGuard.h +++ b/BAN/include/BAN/ScopeGuard.h @@ -13,10 +13,16 @@ namespace BAN { } ~ScopeGuard() { - m_func(); + if (m_enabled) + m_func(); + } + void disable() + { + m_enabled = false; } private: BAN::Function m_func; + bool m_enabled { true }; }; } \ No newline at end of file