BAN: ScopeGuard can now be disabled (it wont call the function)

This commit is contained in:
Bananymous 2023-03-28 01:15:13 +03:00
parent 2f8c9746e3
commit 0ef318633c
1 changed files with 7 additions and 1 deletions

View File

@ -13,10 +13,16 @@ namespace BAN
{ }
~ScopeGuard()
{
if (m_enabled)
m_func();
}
void disable()
{
m_enabled = false;
}
private:
BAN::Function<void()> m_func;
bool m_enabled { true };
};
}