diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2024-01-24 02:29:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 02:29:20 +0100 |
commit | 3b7d9aaa95449a66be36a057aa49e35bcb8acec6 (patch) | |
tree | 2c772ba10530356a7bb4482fe61e207667081fc2 /primedev/util/utils.h | |
parent | efff77f0941df9b6502f6c66a621c1c41a0d1e25 (diff) | |
parent | 7f84bdf8fd5c93286f000bc5f9314eab81128cee (diff) | |
download | NorthstarLauncher-3b7d9aaa95449a66be36a057aa49e35bcb8acec6.tar.gz NorthstarLauncher-3b7d9aaa95449a66be36a057aa49e35bcb8acec6.zip |
Merge branch 'main' into feat/update-for-new-verified-json
Diffstat (limited to 'primedev/util/utils.h')
-rw-r--r-- | primedev/util/utils.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/primedev/util/utils.h b/primedev/util/utils.h index 85922692..1a419607 100644 --- a/primedev/util/utils.h +++ b/primedev/util/utils.h @@ -1,3 +1,23 @@ #pragma once void RemoveAsciiControlSequences(char* str, bool allow_color_codes); + +class ScopeGuard +{ +public: + auto operator=(ScopeGuard&) = delete; + ScopeGuard(ScopeGuard&) = delete; + + ScopeGuard(std::function<void()> callback) : m_callback(callback) {} + ~ScopeGuard() + { + m_callback(); + } + void Dismiss() + { + m_callback = [] {}; + } + +private: + std::function<void()> m_callback; +}; |