#ifndef DUSK_SCOPE_GUARD_HPP #define DUSK_SCOPE_GUARD_HPP #include class SimpleScopeGuard { public: // Store the function in the constructor explicit SimpleScopeGuard(const std::function& func) : m_func(func) {} // Run the function when the object goes out of scope ~SimpleScopeGuard() { if (m_func) m_func(); } private: std::function m_func; }; #endif //DUSK_SCOPE_GUARD_HPP