I have a problem building a program that makes use of the Boost.Compute library.
I use two zip_iterator
s consisting out of a tuple of two float iterators each
to sort two float-vectors with the boost::compute::sort()
function.
My code (both compute::vector
s have been filled with float values before):
typedef compute::vector<float>::iterator Float_Iterator;
typedef boost::tuple<Float_Iterator, Float_Iterator> Sort_Tuple;
typedef compute::zip_iterator<Sort_Tuple> Sort_Iterator;
Sort_Iterator first_sort = compute::make_zip_iterator
(boost::make_tuple(d_x.begin(), d_y.begin()));
Sort_Iterator last_sort = compute::make_zip_iterator
(boost::make_tuple(d_x.end(), d_y.end()));
BOOST_COMPUTE_FUNCTION(bool, compare, (const boost::tuple<float, float> p1, const boost::tuple<float, float> p2),
{
return boost_tuple_get(p1, 0) < boost_tuple_get(p2, 0);
}
);
compute::sort(first_sort, last_sort, compare, queue);
When compiling this, I receive:
error C2782: 'void boost::compute::detail::dispatch_merge_blocks(Iterator,Iterator,Compare,size_t,c onst size_t,const size_t,const size_t,boost::compute::command_queue &)' : **template parameter 'Iterator' is ambiguous**
c:\local\boost_1_62_0\boost\compute\algorithm\detail\merge_sort_on_cpu.hpp(129) : see declaration of 'boost::compute::detail::dispatch_merge_blocks'
could be **'Sort_Iterator'
or 'boost::compute::buffer_iterator<T>'**
with
[
T=value_type
]
As you can see in my code, I call the function with two Sort_Iterator
s I have declared before. Both arguments have the same type, so why should the compiler assume any ambiguity? I don't get this.
However, if I try to explicitly type cast the function arguments, like
compute::sort((Sort_Iterator)first_sort, (Sort_Iterator)last_sort, compare, queue);
the latter part of the error message changes to:
could be **'boost::compute::zip_iterator<Sort_Tuple>'
or 'boost::compute::buffer_iterator<T>'**
with
[
T=value_type
]