diff --git a/src/utils.hh b/src/utils.hh index 5a46b4fd..6a196053 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -112,6 +112,21 @@ inline std::string str_to_str(const std::string& str) return str; } +template +class OnScopeEnd +{ +public: + OnScopeEnd(T func) : m_func(func) {} + ~OnScopeEnd() { m_func(); } +private: + T m_func; +}; + +template +OnScopeEnd on_scope_end(T t) +{ + return OnScopeEnd(t); +} }