variadic tuple_meta_transform
MODIFY
thrust/detail/tuple_meta_transform.h
thrust/detail/tuple_meta_transform.h
#pragma once
#include <thrust/tuple.h>
+#include <thrust/type_traits/integer_sequence.h>
namespace thrust
{
@@ -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;
};

variadic tuple_meta_transform