mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
25 lines
285 B
C
25 lines
285 B
C
|
#pragma once
|
||
|
|
||
|
namespace AK {
|
||
|
|
||
|
template<typename Callback>
|
||
|
class ScopeGuard {
|
||
|
public:
|
||
|
ScopeGuard(Callback callback)
|
||
|
: m_callback(move(callback))
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~ScopeGuard()
|
||
|
{
|
||
|
m_callback();
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
Callback m_callback;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
using AK::ScopeGuard;
|