mirror of
https://github.com/PretendoNetwork/Inkay.git
synced 2026-09-09 10:55:23 -05:00
chore: Introduce common directory to deduplicate shared code
This commit is contained in:
13
common/utils/scope_exit.h
Normal file
13
common/utils/scope_exit.h
Normal 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>;
|
||||
Reference in New Issue
Block a user