protocol for using InputRanges

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 27 11:53:18 PDT 2014


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


More information about the Digitalmars-d mailing list