state of ranges

Steven Schveighoffer schveiguy at yahoo.com
Wed Dec 13 16:33:35 UTC 2017


On 12/12/17 6:43 PM, Luís Marques wrote:
> On Tuesday, 12 December 2017 at 23:25:19 UTC, Neia Neutuladh wrote:
>> Have you noticed performance problems or implementation side 
>> irregularities?
> 
> Well, I was referring to things like in front() having to use code such 
> as `if(!inited) ...; return value`, which was discussed here in the 
> forum in the past.

The proper place to generate the first element, IMO, is in the constructor.

> 
> The performance side hasn't been too bad for me personally (so far...), 
> but I started this thread exactly because I wanted to know if I could 
> move some code to the empty() method of the range, as that would be more 
> convenient and performant. So you could say I mostly noticed the 
> "regularity" part.

Note that there is no compile-time test to figure out when you perform 
your operations, so you can cheat if you want.

I don't think there's a requirement for empty not to do any work, it 
just has to return the same value each time.

-Steve


More information about the Digitalmars-d mailing list