Proposal for SentinelInputRange

John Colvin john.loughran.colvin at gmail.com
Wed Feb 27 17:18:21 PST 2013


On Thursday, 28 February 2013 at 01:14:31 UTC, Timon Gehr wrote:
> On 02/28/2013 02:11 AM, Walter Bright wrote:
>> A SentinelInputRange is an InputRange with the following 
>> additions:
>>
>> 1. a compile time property 'sentinel' that is the terminating 
>> value of
>> the range
>> 2. empty is defined as: empty = (front == sentinel)
>> 3. it is not necessary for empty to be called before front
>>
>> A C style 0-terminated string is an example of a 
>> SentinelInputRange.
>>
>> The additions to std.range would be:
>>
>> 1. isSentinelInputRange(T) which returns true if T is a 
>> SentinelInputRange
>> 2. a unittest
>> 3. documentation of this
>>
>> An addition to std.string would be a function that takes a 
>> char* and
>> returns a SentinelInputRange.
>>
>> Motivation:
>> 1. easy conversion of C strings to ranges
>> 2. necessary for a fast implementation of a lexer
>>
>> Any takers?
>
>
> This is not general enough. The concept is not exclusive to 
> input ranges.

I presume you're remembering that if something is a forward, 
bidirectional or random access range it is also an input range.

What further generality would you want?


More information about the Digitalmars-d mailing list