diff --git a/sol/lua_function.hpp b/sol/lua_function.hpp index b4fe39c4..6a120d62 100644 --- a/sol/lua_function.hpp +++ b/sol/lua_function.hpp @@ -222,10 +222,6 @@ struct explicit_lua_func : public lua_func { template explicit_lua_func(FxArgs&&... fxargs): fx(std::forward(fxargs)...) {} - virtual int operator()(lua_State* L) override { - return (*this)(tuple_types(), typename fx_traits::args_type(), L); - } - template int operator()(types<>, types t, lua_State* L) { return (*this)(types(), t, L); @@ -243,6 +239,10 @@ struct explicit_lua_func : public lua_func { stack::push_reverse(L, std::move(r)); return sizeof...(Ret); } + + virtual int operator()(lua_State* L) override { + return (*this)(tuple_types(), typename fx_traits::args_type(), L); + } }; template @@ -265,8 +265,10 @@ struct explicit_lua_func : public lua_func { template explicit_lua_func(T m, FxArgs&&... fxargs): fx(std::move(m), std::forward(fxargs)...) {} - virtual int operator()(lua_State* L) override { - return (*this)(tuple_types(), typename fx_traits::args_type(), L); + template + int operator()(types, types t, lua_State* L) { + stack::pop_call(L, fx, t); + return 0; } template @@ -274,18 +276,16 @@ struct explicit_lua_func : public lua_func { return (*this)(types(), t, L); } - template - int operator()(types, types t, lua_State* L) { - stack::pop_call(L, fx, t); - return 0; - } - template int operator()(types, types t, lua_State* L) { auto r = stack::pop_call(L, fx, t); - stack::push_reverse(L, r); + stack::push_reverse(L, std::move(r)); return sizeof...(Ret); } + + virtual int operator()(lua_State* L) override { + return (*this)(tuple_types(), typename fx_traits::args_type(), L); + } }; } // sol diff --git a/sol/stack.hpp b/sol/stack.hpp index 18339656..5866d6f5 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -212,27 +212,19 @@ inline void push_tuple(lua_State* L, indices, T&& tuplen) { swallow {'\0', (sol::stack::push(L, std::get(tuplen)), '\0')... }; } -template -auto ltr_pop(lua_State*, F&& f, types<>, Vs&&... vs) -> decltype(f(std::forward(vs)...)) { +template +auto ltr_pop(lua_State*, F&& f, types t, types<>, Vs&&... vs) -> decltype(f(std::forward(vs)...)) { return f(std::forward(vs)...); } -template -auto ltr_pop(lua_State* L, F&& f, types, Vs&&... vs) -> decltype(ltr_pop(L, std::forward(f), types<>(), std::forward(vs)..., pop(L))) { - return ltr_pop(L, std::forward(f), types<>(), std::forward(vs)..., pop(L)); -} -template -auto ltr_pop(lua_State* L, F&& f, types, Vs&&... vs) -> decltype(f(std::forward(vs)..., std::declval(), std::declval()...)) { - return ltr_pop(L, std::forward(f), types(), std::forward(vs)..., pop(L)); +template +auto ltr_pop(lua_State* L, F&& f, types t, types, Vs&&... vs) -> decltype(f(std::declval()...)) { + return ltr_pop(L, std::forward(f), t, types(), std::forward(vs)..., pop(L)); } template auto rtl_pop(lua_State*, F&& f, types, types<>, Vs&&... vs) -> decltype(f(std::forward(vs)...)) { return f(std::forward(vs)...); } -template -auto rtl_pop(lua_State* L, F&& f, types t, types, Vs&&... vs) -> decltype(f(std::declval()...)) { - return rtl_pop(L, std::forward(f), t, types<>(), pop(L), std::forward(vs)...); -} template auto rtl_pop(lua_State* L, F&& f, types t, types, Vs&&... vs) -> decltype(f(std::declval()...)) { return rtl_pop(L, std::forward(f), t, types(), pop(L), std::forward(vs)...); @@ -265,13 +257,13 @@ inline void push_reverse(lua_State* L, std::tuple&& tuplen) { } template -inline auto pop_call(lua_State* L, TFx&& fx, types) -> decltype(detail::ltr_pop(L, std::forward(fx), types())) { - return detail::ltr_pop(L, std::forward(fx), types()); +inline auto pop_call(lua_State* L, TFx&& fx, types t) -> decltype(detail::ltr_pop(L, std::forward(fx), t, t)) { + return detail::ltr_pop(L, std::forward(fx), t, t); } template -inline auto pop_reverse_call(lua_State* L, TFx&& fx, types) -> decltype(detail::rtl_pop(L, std::forward(fx), types(), reversed())) { - return detail::rtl_pop(L, std::forward(fx), types(), reversed()); +inline auto pop_reverse_call(lua_State* L, TFx&& fx, types t) -> decltype(detail::rtl_pop(L, std::forward(fx), t, reversed())) { + return detail::rtl_pop(L, std::forward(fx), t, reversed()); } void push_args(lua_State*) {