mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-12 14:54:10 +00:00
fix tuple_element order
This commit is contained in:
parent
403e83eaf0
commit
c9610b5ae5
9 changed files with 70 additions and 63 deletions
|
@ -11,45 +11,29 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// tppack_at
|
||||
// pack_element
|
||||
//
|
||||
namespace detail {
|
||||
template<std::size_t I, typename Head, typename... Tail>
|
||||
struct tppack_at_impl_1
|
||||
: public sprout::detail::tppack_at_impl_1<I - 1, Tail...>
|
||||
{};
|
||||
template<typename Head, typename... Tail>
|
||||
struct tppack_at_impl_1<0, Head, Tail...> {
|
||||
public:
|
||||
typedef Head type;
|
||||
};
|
||||
template<std::size_t I, typename... Args>
|
||||
struct tppack_at_impl
|
||||
: public sprout::detail::tppack_at_impl_1<I, Args...>
|
||||
{
|
||||
static_assert(I < sizeof...(Args), "I < sizeof...(Args)");
|
||||
};
|
||||
} // namespace detail
|
||||
template<std::size_t I, typename... Args>
|
||||
struct tppack_at
|
||||
: public sprout::detail::tppack_at_impl<I, Args...>
|
||||
struct pack_element
|
||||
: public std::tuple_element<I, sprout::types::type_tuple<Args...> >
|
||||
{};
|
||||
|
||||
//
|
||||
// tppack_c_at
|
||||
// pack_element_c
|
||||
//
|
||||
template<std::size_t I, typename T, T... Args>
|
||||
struct tppack_c_at
|
||||
: public sprout::tppack_at<I, sprout::integral_constant<T, Args>...>::type
|
||||
struct pack_element_c
|
||||
: public sprout::pack_element<I, sprout::integral_constant<T, Args>...>::type
|
||||
{};
|
||||
|
||||
//
|
||||
// fppack_at
|
||||
// pack_get
|
||||
//
|
||||
namespace detail {
|
||||
template<
|
||||
|
@ -57,7 +41,7 @@ namespace sprout {
|
|||
typename sprout::enabler_if<I == 0>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR R
|
||||
fppack_at_impl(Head&& head, Tail&&...) {
|
||||
pack_get_impl(Head&& head, Tail&&...) {
|
||||
return sprout::forward<Head>(head);
|
||||
}
|
||||
template<
|
||||
|
@ -65,16 +49,16 @@ namespace sprout {
|
|||
typename sprout::enabler_if<I != 0>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR R
|
||||
fppack_at_impl(Head&&, Tail&&... tail) {
|
||||
return sprout::detail::fppack_at_impl<I - 1, R>(sprout::forward<Tail>(tail)...);
|
||||
pack_get_impl(Head&&, Tail&&... tail) {
|
||||
return sprout::detail::pack_get_impl<I - 1, R>(sprout::forward<Tail>(tail)...);
|
||||
}
|
||||
} // namespace detail
|
||||
template<std::size_t I, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tppack_at<I, Args&&...>::type
|
||||
fppack_at(Args&&... args) {
|
||||
return sprout::detail::fppack_at_impl<
|
||||
inline SPROUT_CONSTEXPR typename sprout::pack_element<I, Args&&...>::type
|
||||
pack_get(Args&&... args) {
|
||||
return sprout::detail::pack_get_impl<
|
||||
I,
|
||||
typename sprout::tppack_at<I, Args&&...>::type
|
||||
typename sprout::pack_element<I, Args&&...>::type
|
||||
>(sprout::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue