With the latest SVN versions of Phobos and DMD the following static assert fails:
import std.range;
void main() {
auto myIota = iota(1000);
static assert(hasLength!(typeof(myIota)));
}
IMHO this is a blocker for releasing 2.053 because iota is very frequently used with parallel foreach loops and parallel foreach is much less efficient if iterating over a range without a length.
Comment #1 by kennytm — 2011-04-26T08:11:27Z
(SVN? You mean git?)
The problem is length() is an auto-return function, and somehow typeof() cannot find the return type from this function:
--------------------------------------------------
import std.range;
struct X { @property auto length() { return 0; } }
pragma(msg, typeof(X.init.length)); // ()
--------------------------------------------------
Because of this, is(typeof(X.init.length) : ulong) cannot be true, and return hasLength returns false.
This is more a DMD problem than a Phobos problem.