state of ranges
Steven Schveighoffer
schveiguy at yahoo.com
Wed Dec 13 20:33:51 UTC 2017
On 12/13/17 2:33 PM, Jonathan M Davis wrote:
> On Wednesday, December 13, 2017 11:33:35 Steven Schveighoffer via
> Digitalmars-d wrote:
>> I don't think there's a requirement for empty not to do any work, it
>> just has to return the same value each time.
>
> IIRC, when this was discussed previously, it was decided that you really
> couldn't do work in empty. The problem is that under some circumstances at
> least, it's perfectly legitimate to skip calls to empty
The discussion before was whether empty was required to be called before
calling front. It's perfectly acceptable to do work in empty, as long as
you return the same value in 2 subsequent calls to empty without
changing the range between those calls.
The problem is, if you have work done in empty, that doesn't mean you
don't have to do the equivalent work in front. Which is probably what
Luís is after.
The best way I think to have ranges work is to only modify them in
popFront/popBack, and the ctor.
-Steve
More information about the Digitalmars-d
mailing list