Search code examples
cudathrust

Can you pass thrust::device_ptr to thrust::tuple?


Is the below code valid:

typedef thrust::device_ptr<int> IntIterator;
typedef thrust::device_ptr<float> FloatIterator;
typedef thrust::tuple<IntIterator,FloatIterator> IteratorTuple;
typedef thrust::zip_iterator<IteratorTuple> myZipIterator;

I know below is correct, but in the above case we are using pointers:

 typedef thrust::device_vector<float>::iterator       FloatIterator;  
typedef thrust::tuple<FloatIterator, FloatIterator, FloatIterator> FloatIteratorTuple;           
 typedef thrust::zip_iterator<FloatIteratorTuple>                   Float3Iterator;  

Solution

  • Yes, you can, and it works Your previous question. Moreover, reading compiler error messages, I guess that thrust::device_vector<type>::iterator is a typedef of thrust::device_ptr<type>.