diff --git a/thrust/detail/tuple_transform.h b/thrust/detail/tuple_transform.h index 166fab3cb..1de2402b0 100644 --- a/thrust/detail/tuple_transform.h +++ b/thrust/detail/tuple_transform.h @@ -28,332 +28,15 @@ namespace detail template class UnaryMetaFunction, typename UnaryFunction, - unsigned int sz = thrust::tuple_size::value> + typename IndexSequence = thrust::make_index_sequence::value>> struct tuple_transform_functor; template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &, UnaryFunction) - { - return thrust::null_type(); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &, UnaryFunction) - { - return thrust::null_type(); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t)), - f(thrust::get<7>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t)), - f(thrust::get<7>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor -{ - static __host__ - typename tuple_meta_transform::type - do_it_on_the_host(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t)), - f(thrust::get<7>(t)), - f(thrust::get<8>(t))); - } - - static __host__ __device__ - typename tuple_meta_transform::type - do_it_on_the_host_or_device(const Tuple &t, UnaryFunction f) - { - typedef typename tuple_meta_transform::type XfrmTuple; - - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t)), - f(thrust::get<7>(t)), - f(thrust::get<8>(t))); - } -}; - - -template class UnaryMetaFunction, - typename UnaryFunction> - struct tuple_transform_functor + typename UnaryFunction, + size_t... Is> + struct tuple_transform_functor> { static __host__ typename tuple_meta_transform::type @@ -361,16 +44,7 @@ template::type XfrmTuple; - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t)), - f(thrust::get<7>(t)), - f(thrust::get<8>(t)), - f(thrust::get<9>(t))); + return XfrmTuple(f(thrust::get(t))...); } static __host__ __device__ @@ -379,16 +53,7 @@ template::type XfrmTuple; - return XfrmTuple(f(thrust::get<0>(t)), - f(thrust::get<1>(t)), - f(thrust::get<2>(t)), - f(thrust::get<3>(t)), - f(thrust::get<4>(t)), - f(thrust::get<5>(t)), - f(thrust::get<6>(t)), - f(thrust::get<7>(t)), - f(thrust::get<8>(t)), - f(thrust::get<9>(t))); + return XfrmTuple(f(thrust::get(t))...); } };