about summary refs log blame commit diff
path: root/third_party/nix/src/libutil/finally.hh
blob: 2ead8661a6e7147e071cf92e493b20b99f6ba080 (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:
  explicit Finally(std::function<void()> fun) : fun(fun) {}
  ~Finally() { fun(); }
};