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
@@ -4,18 +4,10 @@ extern "C"
}
#include "common/windows/wmi.hpp"
#include "common/windows/unicode.hpp"
#include "common/windows/util.hpp"
STDAPI InitVariantFromStringArray(_In_reads_(cElems) PCWSTR *prgsz, _In_ ULONG cElems, _Out_ VARIANT *pvar);
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* ffBluetoothDetectBattery(FFlist* devices)
{