Difference between input range and forward range
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Tue Nov 10 09:16:40 PST 2015
On 11/10/15 9:28 AM, Shachar Shemesh wrote:
> Please consider the following program:
The problem is that you defined a forward range without implementing all
the primitives :) That is, you can easily make a copy of the range so it
iterates from the current spot (the quintessential feature of forward
ranges). You actually have to do *extra work* to make it a true
input-but-not-forward-range.
I've never made it a secret that I dislike the 'save' requirement. In my
experience, the only time you ever implement 'save' is to do the same
thing as copying the range via =. To the point where people simply don't
use the .save member, and their code always works, so what is the point?
It may as well have been an enum isCopyable.
-Steve
More information about the Digitalmars-d
mailing list