Nix/src/libutil/finally.hh
John Ericson f4ab297b31 Ensure all headers have #pragma once and are in API docs
`///@file` makes them show up in the internal API dos. A tiny few were
missing `#pragma once`.
2023-03-31 23:19:44 -04:00

17 lines
234 B
C++

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