mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
properly use decltype
and throw out the get_return
"type trait". It wasn't very useful anyhow.
This commit is contained in:
parent
946d01d228
commit
0460b33d6c
|
@ -192,11 +192,6 @@ inline int push_userdata(lua_State* L, Key&& metatablekey, Args&&... args) {
|
|||
}
|
||||
} // detail
|
||||
|
||||
template<typename T>
|
||||
struct get_return {
|
||||
typedef decltype(get<T>(nullptr)) type;
|
||||
};
|
||||
|
||||
template <typename T, type expected, typename>
|
||||
struct checker {
|
||||
template <typename Handler>
|
||||
|
|
|
@ -42,13 +42,13 @@ class table : public reference {
|
|||
}
|
||||
|
||||
template<typename Keys, typename... Ret, std::size_t... I>
|
||||
typename return_type<typename stack::get_return<Ret>::type...>::type tuple_get(types<Ret...>, indices<I...>, Keys&& keys) const {
|
||||
auto tuple_get(types<Ret...>, indices<I...>, Keys&& keys) const -> decltype(std::make_tuple(single_get<Ret>(std::get<I>(keys))...)) {
|
||||
return std::make_tuple(single_get<Ret>(std::get<I>(keys))...);
|
||||
}
|
||||
|
||||
template<typename Keys, typename Ret>
|
||||
typename stack::get_return<Ret>::type tuple_get(types<Ret>, indices<0>, Keys&& keys) const {
|
||||
return single_get<Ret>(std::get<0>(keys));
|
||||
template<typename Keys, std::size_t I, typename Ret>
|
||||
auto tuple_get(types<Ret>, indices<I>, Keys&& keys) const -> decltype(single_get<Ret>(std::get<I>(keys))) {
|
||||
return single_get<Ret>(std::get<I>(keys));
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -58,9 +58,9 @@ public:
|
|||
}
|
||||
|
||||
template<typename... Ret, typename... Keys>
|
||||
typename return_type<typename stack::get_return<Ret>::type...>::type get(Keys&&... keys) const {
|
||||
auto get(Keys&&... keys) const -> decltype(tuple_get(types<Ret...>(), types<Ret...>(), std::tie(std::forward<Keys>(keys)...))) {
|
||||
types<Ret...> tr;
|
||||
return tuple_get(tr, tr, std::make_tuple(std::forward<Keys>(keys)...));
|
||||
return tuple_get(tr, tr, std::tie(std::forward<Keys>(keys)...));
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
|
|
Loading…
Reference in New Issue
Block a user