protocol for using InputRanges
Steven Schveighoffer
schveiguy at yahoo.com
Wed Mar 26 05:30:53 PDT 2014
On Wed, 26 Mar 2014 08:29:15 -0400, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Wed, 26 Mar 2014 06:46:26 -0400, Regan Heath <regan at netmail.co.nz>
> wrote:
>> IMO the rules should be something like:
>> - r.empty WILL return false if there is more data available in the
>> range.
>>
>> - r.empty MUST be called before r.front, r.front WILL succeed if
>> r.empty returned false.
>> - r.front WILL repeatably return the current element in the range. It
>> MAY return by value or by reference.
>>
>> - r.empty SHOULD be called before r.popFront, otherwise r.popFront
>> MAY do nothing or throw
>> (could also make this one a 'MUST')
>> - r.popFront WILL advance to the next element in the range.
>
> These two rules are not necessary if you know the range is not empty.
> See the conversation inside this pull:
> https://github.com/D-Programming-Language/phobos/pull/1987
Gah, I didn't cut out the right rules. I meant the two rules that empty
must be called before others. Those are not necessary.
-Steve
More information about the Digitalmars-d
mailing list