protocol for using InputRanges

Adam D. Ruppe destructionator at gmail.com
Sat Mar 22 18:04:31 PDT 2014


On Sunday, 23 March 2014 at 00:50:34 UTC, Walter Bright wrote:
>         auto e = r.front;

Remember that front is a getter property, which means it should 
work like a variable. Typically, reading a variable is not 
destructive and needs no preparation. There's exceptions to the 
rule, but they almost always work this way, so ranges should too.

> If true, this means that r.front will have to cache a copy in 
> many cases.

Indeed, in many of my quick input ranges, I just make front a 
regular variable and popFront updates it to the next item.


More information about the Digitalmars-d mailing list