Hi there,
I stumbled over a weird problem since I updated to CUDA 12 and the latest Thrust release.
It appears it has something to do with hidden iterator semantics with iterator_adaptor, and with the settings for C++ 2017 standard.
I actually took the example for iterator_adaptor to build an iterator that actually repeats the first n elements like 1,2,3,…,n,1,2,3,…,n, 1,2,3,…n.
// derive repeat_iterator from iterator_adaptor
template
class infinite_repeat_iterator
: public thrust::iterator_adaptor<
infinite_repeat_iterator, // the first template parameter is the name of the iterator we’re creating
Iterator // the second template parameter is the name of the iterator we’re adapting
// we can use the default for the additional template parameters
>
{
public:
// shorthand for the name of the iterator_adaptor we’re deriving from
typedef thrust::iterator_adaptor<
infinite_repeat_iterator,
Iterator
> super_t;
host device
infinite_repeat_iterator(const Iterator &x, int n) : super_t(x), begin(x), n(n) {}
// befriend thrust::iterator_core_access to allow it access to the private interface below
friend class thrust::iterator_core_access;
private:
// repeat each element of the adapted range n times
unsigned int n;
// used to keep track of where we began
const Iterator begin;
// it is private because only thrust::iterator_core_access needs access to it
host device
typename super_t::reference dereference() const
{
return *(begin + (this->base() - begin) % n);
}
};
The compiler expands this and says this …
/include/thrust/detail/tuple.inl(479): error: function “custom_iterators::infinite_repeat_iterator::operator=(const custom_iterators::infinite_repeat_iterator<thrust::detail::normal_iterator<thrust::device_ptr>> &) [with Iterator=thrust::detail::normal_iterator<thrust::device_ptr>]” (declared implicitly) cannot be referenced – it is a deleted function
cons& operator=(const cons& u) { head = u.head; return *this; }
^
It seems that the implicit assignment operator has been deleted for some reason. And that I need to add something to my customized iterator definition.
I am stuck. I hope someone could help here. It must be something simple, but I cannot find it.
Many thanks in advance
Andreas