From 0460b33d6c0d52b3c32d4019e2cc6fb0f0441a4c Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 21 Jul 2015 19:34:48 -0400 Subject: [PATCH] properly use `decltype` and throw out the `get_return` "type trait". It wasn't very useful anyhow. --- sol/stack.hpp | 5 ----- sol/table.hpp | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/sol/stack.hpp b/sol/stack.hpp index d0e4c4a8..c03cfea6 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -192,11 +192,6 @@ inline int push_userdata(lua_State* L, Key&& metatablekey, Args&&... args) { } } // detail -template -struct get_return { - typedef decltype(get(nullptr)) type; -}; - template struct checker { template diff --git a/sol/table.hpp b/sol/table.hpp index b58d69d4..366c1132 100644 --- a/sol/table.hpp +++ b/sol/table.hpp @@ -42,13 +42,13 @@ class table : public reference { } template - typename return_type::type...>::type tuple_get(types, indices, Keys&& keys) const { + auto tuple_get(types, indices, Keys&& keys) const -> decltype(std::make_tuple(single_get(std::get(keys))...)) { return std::make_tuple(single_get(std::get(keys))...); } - template - typename stack::get_return::type tuple_get(types, indices<0>, Keys&& keys) const { - return single_get(std::get<0>(keys)); + template + auto tuple_get(types, indices, Keys&& keys) const -> decltype(single_get(std::get(keys))) { + return single_get(std::get(keys)); } public: @@ -58,9 +58,9 @@ public: } template - typename return_type::type...>::type get(Keys&&... keys) const { + auto get(Keys&&... keys) const -> decltype(tuple_get(types(), types(), std::tie(std::forward(keys)...))) { types tr; - return tuple_get(tr, tr, std::make_tuple(std::forward(keys)...)); + return tuple_get(tr, tr, std::tie(std::forward(keys)...)); } template