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 c7286396d8
commit 6a6717cdd3
1 changed files with 7 additions and 1 deletions

View File

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