aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/finally.hh
blob: db654301fdd5a29f0de0f91c2b58e1001925b320 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once
///@file

/**
 * 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(); }
};