std.range.iota enhancement: supporting more types (AKA issue 10762)
Francesco Cattoglio
francesco.cattoglio at gmail.com
Tue Dec 24 03:30:35 PST 2013
On Tuesday, 24 December 2013 at 10:44:54 UTC, bearophile wrote:
> Francesco Cattoglio:
> One possible disadvantage is when you want an array of various
> iota (all of the same indexed type, like int) (currently this
> doesn't compile), this was a potential use case for me:
>
> void main() {
> import std.range: iota;
> auto intervals = [iota(10), iota(2, 7), iota(2, 15, 2)];
> }
>
> Bye,
> bearophile
Nice point: the issue here is that every iota defines its own
return type. I will see if there's some way around this on the
library side. The "user side" workaround is simple:
void main() {
import std.range: iota;
auto intervals = [iota(0, 10, 1), iota(2, 7, 1), iota(2, 15,
2)];
}
More information about the Digitalmars-d
mailing list