protocol for using InputRanges

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Mar 27 12:50:54 PDT 2014


On 3/27/14, 11:53 AM, Steven Schveighoffer wrote:
> On Thu, 27 Mar 2014 12:02:16 -0400, monarch_dodra
> <monarchdodra at gmail.com> wrote:
>
>> On Thursday, 27 March 2014 at 15:19:37 UTC, Andrei Alexandrescu wrote:
>>> On 3/27/14, 3:49 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
>>>> I was originally going to do that, but then I took a closer look at the
>>>> documentation, which says ([1] in the documentation of
>>>> `isInputRange()`):
>>>>
>>>> "Calling r.front is allowed only if calling r.empty has, or would have,
>>>> returned false."
>>>
>>> Probably we need to amend that. For efficient ranges, front() and
>>> popFront() should only be guaranteed to work if either empty() or
>>> length() were evaluated first, and they returned false or nonzero,
>>> respectively.
>>
>> I just want to point out that I think allowing empty to have an
>> *observable* side effect will have cataclysmic repercussion in
>> validating a release build, what with all our "assert(!empty);" calls
>> and all.
>
> This is an excellent point. assert(!empty) is everywhere.
>
> -Steve

Yah, agreed. -- Andrei


More information about the Digitalmars-d mailing list