nVidia Thrust: device_ptr Const-Correctness
问题 In my project which makes extensive use of nVidia CUDA, I sometimes use Thrust for things that it does very, very well. Reduce is one algorithm that is particularly well implemented in that library and one use of reduce is to normalise a vector of non-negative elements by dividing each element by the sum of all elements. template <typename T> void normalise(T const* const d_input, const unsigned int size, T* d_output) { const thrust::device_ptr<T> X = thrust::device_pointer_cast(const_cast<T*