#pragma once #include namespace BAN { class ScopeGuard { public: ScopeGuard(const BAN::Function& func) : m_func(func) { } ~ScopeGuard() { if (m_enabled) m_func(); } void disable() { m_enabled = false; } private: BAN::Function m_func; bool m_enabled { true }; }; }