Why does filter return const?

bearophile bearophileHUGS at lycos.com
Thu Apr 10 04:44:21 PDT 2014


Edwin van Leeuwen:

> 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.

Mixing functional-style programming with mutation is a source of 
troubles. If you want to do that it's safer and more clear to use 
normal imperative code. (There is also the copy() function, but I 
think it doesn't help you in this case).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list