初始化内容

This commit is contained in:
2026-09-16 14:07:40 +08:00
parent 6934b390bf
commit 4f643c1e7c
18350 changed files with 6088489 additions and 305 deletions
+47
View File
@@ -0,0 +1,47 @@
// https://github.com/kunitoki/LuaBridge3
// Copyright 2021, kunitoki
// Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
// SPDX-License-Identifier: MIT
#pragma once
#include "Config.h"
#include "Stack.h"
namespace luabridge::detail {
//=================================================================================================
/**
* @brief Scope guard.
*/
template <class F>
class ScopeGuard
{
public:
template <class V>
explicit ScopeGuard(V&& v)
: m_func(std::forward<V>(v))
, m_shouldRun(true)
{
}
~ScopeGuard()
{
if (m_shouldRun)
m_func();
}
void reset() noexcept
{
m_shouldRun = false;
}
private:
F m_func;
bool m_shouldRun;
};
template <class F>
ScopeGuard(F&&) -> ScopeGuard<F>;
} // namespace luabridge::detail