From e6b4ffb588daa679ccd13025859096277d149fe9 Mon Sep 17 00:00:00 2001 From: Shewer Lu Date: Wed, 25 Oct 2023 01:33:43 +0800 Subject: [PATCH] Update luatype_boost_optional.h --- src/lib/luatype_boost_optional.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/lib/luatype_boost_optional.h b/src/lib/luatype_boost_optional.h index 106783a..c75a466 100644 --- a/src/lib/luatype_boost_optional.h +++ b/src/lib/luatype_boost_optional.h @@ -2,22 +2,36 @@ #define LUATYPE_BOOST_OPTIONAL_H #include "lua_templates.h" +#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L +#include +#else #include +#endif // C++17 + +namespace ns { +#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L +using std::optional; + +#else +using boost::optional; + +#endif // C++17 + template -struct LuaType> { - static void pushdata(lua_State *L, boost::optional o) { +struct LuaType> { + static void pushdata(lua_State *L, ns::optional o) { if (o) LuaType::pushdata(L, *o); else lua_pushnil(L); } - static boost::optional &todata(lua_State *L, int i, C_State *C) { + static ns::optional &todata(lua_State *L, int i, C_State *C) { if (lua_type(L, i) == LUA_TNIL) - return C->alloc>(); + return C->alloc>(); else - return C->alloc>(LuaType::todata(L, i, C)); + return C->alloc>(LuaType::todata(L, i, C)); } };