mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Nice segmentation fault, GCC
This commit is contained in:
parent
2706f19976
commit
63b9f748f7
|
@ -85,6 +85,12 @@ namespace sol {
|
|||
}
|
||||
} // stack_detail
|
||||
|
||||
template <typename T>
|
||||
int set_ref(lua_State* L, T&& arg, int tableindex = -2) {
|
||||
push(L, std::forward<T>(arg));
|
||||
return luaL_ref(L, tableindex);
|
||||
}
|
||||
|
||||
inline void remove(lua_State* L, int index, int count) {
|
||||
if (count < 1)
|
||||
return;
|
||||
|
|
|
@ -334,11 +334,9 @@ namespace sol {
|
|||
template <typename... Args>
|
||||
basic_table_core& add(Args&&... args) {
|
||||
auto pp = stack::push_pop(*this);
|
||||
auto action = [&](auto&& arg) {
|
||||
stack::push(base_t::lua_state(), std::forward<decltype(arg)>(arg));
|
||||
luaL_ref(base_t::lua_state(), -2);
|
||||
(void)detail::swallow{0,
|
||||
(stack::set_ref(base_t::lua_state(), std::forward<Args>(args)), 0)...
|
||||
};
|
||||
(void)detail::swallow{0, (action(std::forward<Args>(args)), 0)...};
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user