Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
variadic tuple_meta_transform
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcorrigan committed Oct 12, 2020
1 parent 3eba25f commit 53a1d25
Showing 1 changed file with 6 additions and 137 deletions.
143 changes: 6 additions & 137 deletions thrust/detail/tuple_meta_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <thrust/tuple.h>
#include <thrust/type_traits/integer_sequence.h>

namespace thrust
{
Expand All @@ -26,148 +27,16 @@ namespace detail

template<typename Tuple,
template<typename> class UnaryMetaFunction,
unsigned int sz = thrust::tuple_size<Tuple>::value>
typename IndexSequence = thrust::make_index_sequence<thrust::tuple_size<Tuple>::value>>
struct tuple_meta_transform;

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,0>
{
typedef null_type type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,1>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,2>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,3>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,4>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,5>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<4,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,6>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<4,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<5,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,7>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<4,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<5,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<6,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,8>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<4,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<5,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<6,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<7,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,9>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<4,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<5,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<6,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<7,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<8,Tuple>::type>::type
> type;
};

template<typename Tuple,
template<typename> class UnaryMetaFunction>
struct tuple_meta_transform<Tuple,UnaryMetaFunction,10>
template<typename> class UnaryMetaFunction,
size_t... Is>
struct tuple_meta_transform<Tuple, UnaryMetaFunction, thrust::index_sequence<Is...>>
{
typedef thrust::tuple<
typename UnaryMetaFunction<typename thrust::tuple_element<0,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<1,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<2,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<3,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<4,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<5,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<6,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<7,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<8,Tuple>::type>::type,
typename UnaryMetaFunction<typename thrust::tuple_element<9,Tuple>::type>::type
typename UnaryMetaFunction<typename thrust::tuple_element<Is,Tuple>::type>::type...
> type;
};

Expand Down

0 comments on commit 53a1d25

Please sign in to comment.