lix/src/libutil/finally.hh

15 lines
248 B
C++
Raw Normal View History

#pragma once
2016-11-07 13:35:47 +00:00
#include <functional>
/* A trivial class to run a function at the end of a scope. */
class Finally
{
private:
std::function<void()> fun;
public:
Finally(std::function<void()> fun) : fun(fun) { }
~Finally() { fun(); }
};