tvl-depot/third_party/nix/src/libutil/finally.hh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

14 lines
252 B
C++
Raw Normal View History

#pragma once
2016-11-07 14:35:47 +01:00
#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(); }
};