Common: add on_scope_exit utility for scope-based resource management

This commit is contained in:
李通洲
2026-01-13 18:33:02 +08:00
parent 49fc95689d
commit e6bd1c340f
5 changed files with 23 additions and 37 deletions
+1 -9
View File
@@ -6,6 +6,7 @@ extern "C" {
#include "detection/gpu/gpu.h"
#include "detection/gpu/gpu_driver_specific.h"
}
#include "common/windows/util.hpp"
#include <wsl/winadapter.h>
#include <directx/dxcore.h>
@@ -16,15 +17,6 @@ extern "C" {
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
template <typename Fn>
struct on_scope_exit {
on_scope_exit(Fn &&fn): _fn(std::move(fn)) {}
~on_scope_exit() { this->_fn(); }
private:
Fn _fn;
};
extern "C"
const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus)
{