about summary refs log blame commit diff
path: root/third_party/nix/src/libutil/finally.hh
blob: 8d3083b6a3acd34a13ca66c138c9b842c26f1020 (plain) (tree)
1
2
3
4
5
6
7
8
9

            

                     
                                                              


                            
 


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