From 86b16dc61b924250524f621a17f2e41f5ab45edb Mon Sep 17 00:00:00 2001 From: ThePhD Date: Mon, 2 Dec 2013 20:12:25 -0500 Subject: [PATCH] GCC is still not compiling, complaining about detail::ltr_pop and not being able to find a proper overload. I'm not sure why it's complaining, I'll have to look in more detail soon. --- sol/function.hpp | 43 +++++++++---------------------------------- sol/lua_function.hpp | 2 +- sol/stack.hpp | 12 ++++++------ sol/table.hpp | 1 - 4 files changed, 16 insertions(+), 42 deletions(-) diff --git a/sol/function.hpp b/sol/function.hpp index da976d04..d77bf480 100644 --- a/sol/function.hpp +++ b/sol/function.hpp @@ -30,50 +30,25 @@ namespace sol { class function : virtual public reference { private: - template - struct invoker { - template - static std::tuple call(const function& ref, Args&&... args) { - lua_pcall( ref.state( ), sizeof...( Args ), sizeof...( Ret ), 0 ); - return std::make_tuple(stack::pop(ref.state())...); - } - }; - - template<> - struct invoker<> { - template - static void call(const function& ref, Args&&... args) { - lua_pcall( ref.state( ), sizeof...( Args ), 0, 0 ); - } - }; - - template - struct invoker { - template - static T call(const function& ref, Args&&... args) { - lua_pcall( ref.state( ), sizeof...( Args ), 1, 0 ); - return stack::pop( ref.state( ) ); - - } - }; - template - std::tuple invoke( types, std::size_t n ) { + std::tuple call( types, std::size_t n ) { + typedef typename std::decay)>::type maketuple_t; + maketuple_t m = &std::make_tuple; lua_pcall( state( ), n, sizeof...( Ret ), 0 ); - return stack::pop_call( state( ), std::make_tuple, types() ); + return stack::pop_call( state( ), m, types() ); } template - Ret invoke( types, std::size_t n ) { + Ret call( types, std::size_t n ) { lua_pcall( state( ), n, 1, 0 ); return stack::pop( state( ) ); } - void invoke( types, std::size_t n ) { + void call( types, std::size_t n ) { lua_pcall( state( ), n, 0, 0 ); } - void invoke( types<>, std::size_t n ) { + void call( types<>, std::size_t n ) { lua_pcall( state( ), n, 0, 0 ); } @@ -84,10 +59,10 @@ public: } template - auto invoke(Args&&... args) -> decltype(invoke( types( ), sizeof...( Args ) )) { + auto invoke(Args&&... args) -> decltype(call(types( ), sizeof...( Args ))) { push( ); stack::push_args( state( ), std::forward( args )... ); - return invoke( types( ), sizeof...( Args ) ); + return call( types( ), sizeof...( Args ) ); } }; } // sol diff --git a/sol/lua_function.hpp b/sol/lua_function.hpp index f295030e..225fda71 100644 --- a/sol/lua_function.hpp +++ b/sol/lua_function.hpp @@ -128,7 +128,7 @@ struct explicit_lua_func : public lua_func { } template - int operator () (types, types, lua_State* L) { + int operator () (types, types t, lua_State* L) { stack::pop_call(L, fx, t); return 0; } diff --git a/sol/stack.hpp b/sol/stack.hpp index 9fcfb3c4..c0d262ba 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -160,16 +160,16 @@ inline void push(lua_State* L, indices, const T& tuplen) { } template -auto ltr_pop(T&& extra, F f, types<>, Vs&&... vs) +auto ltr_pop(T&&, F&& f, types<>, Vs&&... vs) -> decltype(f(std::forward(vs)...)) { return f(std::forward(vs)...); } // take head, produce value from it, pass after other values template -auto ltr_pop(lua_State* L, F f, types, Vs&&... vs) --> decltype(ltr_pop(L, f, types{}, std::forward(vs)..., pop(L))) { - return ltr_pop(L, f, types{}, std::forward(vs)..., pop(L)); +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)); } } // detail @@ -180,8 +180,8 @@ inline void push(lua_State* L, const std::tuple& tuplen) { } template -inline auto pop_call(lua_State* L, TFx&& fx, types t)->decltype(detail::ltr_pop(L, fx, t)) { - return detail::ltr_pop(L, fx, t); +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()); } template diff --git a/sol/table.hpp b/sol/table.hpp index 9b9d6ab2..679a817b 100644 --- a/sol/table.hpp +++ b/sol/table.hpp @@ -89,7 +89,6 @@ private: template table& set_fx(std::false_type, T&& key, TFx&& fx) { - typedef typename std::remove_pointer::type>::type clean_fx; typedef typename std::decay::type ptr_fx; std::unique_ptr sptr(new detail::explicit_lua_func(std::forward(fx))); return set_fx(std::forward(key), std::move(sptr));