blob: dee2e8d2ff278dda750b119c2ee8a093a579985f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#pragma once
/* A trivial class to run a function at the end of a scope. */
template<typename Fn>
class Finally
{
private:
Fn fun;
public:
Finally(Fn fun) : fun(std::move(fun)) { }
~Finally() { fun(); }
};
|