Line data Source code
1 : #pragma once 2 : 3 : #include <thrust/transform.h> 4 : #include <thrust/iterator/iterator_traits.h> 5 : 6 : namespace elsa 7 : { 8 : /// @brief Cast input range to type from output range 9 : /// @ingroup transforms 10 : template <class InputIter, class OutIter> 11 : void cast(InputIter first, InputIter last, OutIter out) 12 452 : { 13 452 : using From = thrust::remove_cvref_t<thrust::iterator_value_t<InputIter>>; 14 452 : using To = thrust::remove_cvref_t<thrust::iterator_value_t<OutIter>>; 15 : 16 452 : thrust::transform(first, last, out, 17 27103 : [] __host__ __device__(const From& val) { return To(val); }); 18 452 : } 19 : } // namespace elsa