mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Ha ha haaa I forgot std::pair is a tuple-like type .-.
This commit is contained in:
parent
83ec159da1
commit
20d85850ea
|
@ -63,7 +63,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T get() const {
|
decltype(auto) get() const {
|
||||||
return stack::get<T>(L, index);
|
return stack::get<T>(L, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,6 +379,13 @@ struct getter<std::tuple<Args...>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename A, typename B>
|
||||||
|
struct getter<std::pair<A, B>> {
|
||||||
|
static decltype(auto) get(lua_State* L, int index = -1) {
|
||||||
|
return std::pair<decltype(stack::get<A>(L, index)), decltype(stack::get<B>(L, index))>(stack::get<A>(L, index), stack::get<B>(L, index + 1));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, type expected, typename>
|
template <typename T, type expected, typename>
|
||||||
struct checker {
|
struct checker {
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
|
@ -487,6 +494,15 @@ struct popper<std::tuple<Args...>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B>
|
||||||
|
struct popper<std::pair<A, B>> {
|
||||||
|
inline decltype(auto) pop(lua_State* L) {
|
||||||
|
decltype(auto) r = get<std::pair<A, B>>(L, lua_gettop(L) - 2 + 1);
|
||||||
|
lua_pop(L, 2);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T, typename>
|
template<typename T, typename>
|
||||||
struct pusher {
|
struct pusher {
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
|
@ -741,6 +757,16 @@ struct pusher<std::tuple<Args...>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename A, typename B>
|
||||||
|
struct pusher<std::pair<A, B>> {
|
||||||
|
template <typename T>
|
||||||
|
static int push(lua_State* L, T&& t) {
|
||||||
|
int pushcount = stack::push(L, detail::forward_get<0>(t));
|
||||||
|
pushcount += stack::push(L, detail::forward_get<1>(t));
|
||||||
|
return pushcount;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, bool, typename>
|
template <typename T, bool, typename>
|
||||||
struct field_getter {
|
struct field_getter {
|
||||||
template <typename Key>
|
template <typename Key>
|
||||||
|
@ -766,6 +792,18 @@ struct field_getter<std::tuple<Args...>, b, C> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, bool b, typename C>
|
||||||
|
struct field_getter<std::pair<A, B>, b, C> {
|
||||||
|
template <typename Keys>
|
||||||
|
void apply(lua_State* L, Keys&& keys, int tableindex) {
|
||||||
|
get_field<b>(L, detail::forward_get<0>(keys), tableindex);
|
||||||
|
get_field<false>(L, detail::forward_get<1>(keys), tableindex);
|
||||||
|
reference saved(L, -1);
|
||||||
|
lua_pop(L, static_cast<int>(2 + 1));
|
||||||
|
saved.push();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct field_getter<T, true, std::enable_if_t<meta::is_c_str<T>::value>> {
|
struct field_getter<T, true, std::enable_if_t<meta::is_c_str<T>::value>> {
|
||||||
template <typename Key>
|
template <typename Key>
|
||||||
|
|
|
@ -286,6 +286,9 @@ struct is_proxy_primitive<std::reference_wrapper<T>> : std::true_type { };
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct is_proxy_primitive<std::tuple<Args...>> : std::true_type { };
|
struct is_proxy_primitive<std::tuple<Args...>> : std::true_type { };
|
||||||
|
|
||||||
|
template <typename A, typename B>
|
||||||
|
struct is_proxy_primitive<std::pair<A, B>> : std::true_type { };
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_unique_usertype : std::false_type {};
|
struct is_unique_usertype : std::false_type {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user