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