about summary refs log tree commit diff
path: root/third_party/nix/src/libutil/finally.hh
#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(); }
};