about summary refs log blame commit diff
path: root/src/libutil/finally.hh
blob: 7760cfe9a4104353b921f9d5356170d3debeacdb (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14

            

                     









                                                              
#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:
    Finally(std::function<void()> fun) : fun(fun) { }
    ~Finally() { fun(); }
};