BAN: ScopeGuard can now be disabled (it wont call the function)
This commit is contained in:
parent
2f8c9746e3
commit
0ef318633c
|
@ -13,10 +13,16 @@ namespace BAN
|
||||||
{ }
|
{ }
|
||||||
~ScopeGuard()
|
~ScopeGuard()
|
||||||
{
|
{
|
||||||
m_func();
|
if (m_enabled)
|
||||||
|
m_func();
|
||||||
|
}
|
||||||
|
void disable()
|
||||||
|
{
|
||||||
|
m_enabled = false;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
BAN::Function<void()> m_func;
|
BAN::Function<void()> m_func;
|
||||||
|
bool m_enabled { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue