Combining infinite ranges
Graham Fawcett
fawcett at uwindsor.ca
Thu Jun 3 08:01:14 PDT 2010
On Wed, 02 Jun 2010 20:21:49 -0500, Andrei Alexandrescu wrote:
>
> My point was that there's no need to sit down and implement
> functionality. Just write
>
> auto enumerate(R)(R r) if (isInputRange!R) {
> return zip(iota(0, size_t.max), r);
> }
Should this work with v2.043? I get an error if I try to enumerate an
array, for example:
/* example.d */
import std.range;
auto enumerate(R)(R r) if (isInputRange!R) {
return zip(iota(0, size_t.max), r);
}
void main() {
auto e = enumerate([10,20,30]);
}
$ dmd example.d
/usr/include/d/dmd/phobos/std/range.d(1773): Error: cannot implicitly
convert expression (&this.ranges._field_field_0.front) of type uint
delegate() to uint*
(The error message is unfortunate: it doesn't indicate the offending
expression in example.d.)
Thanks,
Graham
More information about the Digitalmars-d
mailing list