chore: Introduce common directory to deduplicate shared code

This commit is contained in:
Ash Logan 2024-11-21 13:19:06 +11:00
commit ea71879bb1
22 changed files with 110 additions and 278 deletions

13
common/utils/scope_exit.h Normal file
View file

@ -0,0 +1,13 @@
#pragma once
#include <functional>
// https://stackoverflow.com/a/61242721
template<typename F>
struct scope_exit
{
F func;
explicit scope_exit(F&& f): func(std::forward<F>(f)) {}
~scope_exit() { func(); }
};
template<typename F> scope_exit(F&& frv) -> scope_exit<F>;