Skip to content

Commit

Permalink
fixed boost::optional error
Browse files Browse the repository at this point in the history
Signed-off-by: shewer <[email protected]>
  • Loading branch information
shewer committed Oct 25, 2023
1 parent dba5d1b commit 5cf4a51
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/lib/luatype_boost_optional.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
#ifndef LUATYPE_BOOST_OPTIONAL_H
#define LUATYPE_BOOST_OPTIONAL_H

#include "lua_templates.h"
#if __cplusplug >= 201703L || _MSVC_VER >=201703L
#include <optional>
#else
#include <boost/optional.hpp>
#endif // C++17
//
#include "lua_templates.h"



namespace ns {
#if __cplusplug >= 201703L || _MSVC_VER >=201703L
using std::optional;
#else
using boost::optional;
#endif// C++17

}// namespace

template<typename T>
struct LuaType<boost::optional<T>> {
static void pushdata(lua_State *L, boost::optional<T> o) {
struct LuaType<ns::optional<T>> {
static void pushdata(lua_State *L, ns::optional<T> o) {
if (o)
LuaType<T>::pushdata(L, *o);
else
lua_pushnil(L);
}

static boost::optional<T> &todata(lua_State *L, int i, C_State *C) {
static ns::optional<T> &todata(lua_State *L, int i, C_State *C) {
if (lua_type(L, i) == LUA_TNIL)
return C->alloc<boost::optional<T>>();
return C->alloc<ns::optional<T>>();
else
return C->alloc<boost::optional<T>>(LuaType<T>::todata(L, i, C));
return C->alloc<ns::optional<T>>(LuaType<T>::todata(L, i, C));
}
};

Expand Down

0 comments on commit 5cf4a51

Please sign in to comment.