On 2/9/2013 12:43 PM, Walter Bright wrote:> Perhaps we can formalize this a bit. Define a SentinelInputRange, which has an
> additional manifest constant with the name 'sentinel'. empty becomes defined 
as:
>
>      empty = front == sentinel;
>
> popFront() does not advance if empty. Advancing over a SentinelInputRange can 
be
> done the usual:
>
>      for (r = range; !r.empty; r.popFront()) { auto e = r.front; }
>
> or can be done as:
>
>      for (r = range; r.front != sentinel; r.popFront()) { auto e = r.front; }

If it's not clear, SentinelInputRange.front can be called *before* checking empty. If it is empty, then the sentinel is returned.

Reply via email to