On Thursday, 10 April 2014 at 10:30:19 UTC, Edwin van Leeuwen wrote:
I'd like to filter a range and then change the filtered results, but FilterResult returns a const. Is there any (straightforward) way of doing what I want?

I guess I could create duplicates, but I would like my changes also to be reflected in the original range.

Cheers, Edwin

It doesn't. It returns front, and by Ref if at all possible too.

//----
void main()
{
    auto arr = iota(0, 10).array();
    foreach (ref e; arr.filter!"a%2"())
        --e;
    writeln(arr); //duplicate evens
}
//----
[0, 0, 2, 2, 4, 4, 6, 6, 8, 8]
//----

There must be something else that is wrong. What are you trying to do?

Reply via email to