I want thrust transform-iterator to give me a writable lvalue and/or for the transformation function to modify the iterator target. Here’s a minimal nonworking example.
host_vector t(3) ;
t[0]=8;
auto f=[&](int i) {return ++i;};
auto u=make_transform_iterator(t.begin(), f);
*u=5; // I want this to increment t[0] and/or set it to 5.
The compiler complains that *u is not an lvalue.
W/o that line the program compiles and runs, but accessing *u does not modify t.
I googled a lot, and tried all the obvious variations of that lot.
It’s possible that the reference optional argument to make_transform_iterator is relevant. However I can find neither any examples nor any documentation short of reading the thrust source code.
Why do I want this? I want to use gather to write into the first elements of a vector of pairs. If there’s another way to do this, short of creating and storing a separate vector, then thanks.