std.range.iota enhancement: supporting more types (AKA issue 10762)

bearophile bearophileHUGS at lycos.com
Mon Dec 23 07:23:44 PST 2013


Francesco Cattoglio:

> - iota() currently returns a Random Access range, and I'm sure 
> nobody would agree to downgrade the result to a ForwardRange or 
> an InputRange, because that would break an unknown amount of 
> code.
> ...
> Everything else ends up being the same as before: popBack() can 
> be optimized if {--c;} is valid code, the opIndex, opSlice, 
> back and length methods will take O(n) time, no way around this 
> sadly.

If the new iota accepts new types, then no existing code is using 
iota for such cases. So you are not breaking code is you offer a 
more restricted range for such types, avoiding O(n) behavior for 
them.

Bye,
bearophile


More information about the Digitalmars-d mailing list