I am currently trying to use the Thrust library and I am having issues with the return types.
device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
pair<int*, int*> result= minmax_element(input.begin(), input.end());
gives the error:
error : no suitable conversion function from "const thrust::detail::normal_iterator<thrust::device_ptr<int>>" to "int *" exists
Could someone please explain to me how work out what the return type should be?
according to the documentation the return type is
thrust::pair<ForwardIterator,ForwardIterator>
However this not not working for me, could someone please explain!
Thanks!
When naming a template parameter,
ForwardIteratordoes not name any particular type. For our purposes, we can think of it as a placeholder for the type of iterator given tothrust::minmax_element:So
minmax_elementreturns apairof whatever type of iterator is given to it as arguments.In your case,
minmax_elementreturns apairofdevice_vector<int>::iterators. You can make your code compile by makingresultthe appropriatepair: