[SOLVED] writable lvalue from thrust transform-iterator

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.

Since my post, I read the Thrust changelog to see what might be new. Whaddayaknow: Thrust now has a transform_output_iterator! There’s also a new example, transform_output_iterator.cu. This does most of what I want. It’s write-only. With it, you can replace the target value either in the transformation function, or as an assignment, thus: *outpoint = newval;

Since transform_output_iterator is output-only, you cannot access the former value, and so cannot replace only one field of the value. However I rewrote my code not to need that. If I really needed it, a solution using two pointers is now imagineable.

transform_output_iterator is undocumented: http://thrust.github.io/doc/index.html does not mention it. Googling transform_output_iterator gives the rare result of a very small list of answers, instead of pages and pages. I’m hoping that it will be documented soon (hint!). There really was no way I could have discovered its existence w/o reading the changelog. It was a surprise to see this incognito function.

transform_output_iterator was proposed for boost but not included, because apparently you can simulate it with other boost functions.