Nice segmentation fault, GCC

This commit is contained in:
ThePhD 2016-06-19 19:13:01 -04:00
parent 2706f19976
commit 63b9f748f7
2 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}