Andrei Alexandrescu wrote:
Sergey Gromov wrote:
There are actually two issues:

1. Most of the std.algorithm and std.range functions claim that they accept input ranges but take them *by value*. This violates input ranges' non-copyable contract.

2. A whole bunch of algorithms is required similar to those we have now but accepting their range arguments by reference and mutating them.

Do I miss something?  The ranges do not seem as universal to me anymore.

This issue is solved by save(), see http://erdani.com/publications/on-iteration.html. We need to make one more pass through the ranges and the range-related stuff in Phobos to use save().

Thinking about it, save() can save the day if all the range manipulation functions are changed to receive ranges by reference and to keep value ranges by pointer internally, and use save() if they really want a copy. Otherwise, if take() still returns Take!() value and copy() still receives it by value, save() won't change anything.

Reply via email to