BAN: Add basic ScopeGuard
This commit is contained in:
parent
1b9f7aa815
commit
7c6d474a3a
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <BAN/Function.h>
|
||||
|
||||
namespace BAN
|
||||
{
|
||||
|
||||
class ScopeGuard
|
||||
{
|
||||
public:
|
||||
ScopeGuard(const BAN::Function<void()>& func)
|
||||
: m_func(func)
|
||||
{ }
|
||||
~ScopeGuard()
|
||||
{
|
||||
m_func();
|
||||
}
|
||||
private:
|
||||
BAN::Function<void()> m_func;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue