From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/common/windows/util.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/common/windows/util.hpp (limited to 'src/common/windows/util.hpp') diff --git a/src/common/windows/util.hpp b/src/common/windows/util.hpp new file mode 100644 index 0000000..939f6bb --- /dev/null +++ b/src/common/windows/util.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +template +struct on_scope_exit { + static_assert(std::is_nothrow_move_constructible::value, + "Fn must be nothrow move constructible"); + + explicit on_scope_exit(Fn&& fn) noexcept + : _fn(std::move(fn)) {}; + on_scope_exit(const on_scope_exit&) = delete; + on_scope_exit& operator=(const on_scope_exit&) = delete; + ~on_scope_exit() noexcept { + this->_fn(); + } + + private: + Fn _fn; +}; -- cgit v1.2.3