12.08.2010 17:13, simendsjo wrote:
The spec doesn't mention anything about block statements in typeof
declarations.
//typeof({1}) a; // found } expecting ;
//typeof({1}()) b; // same as a
typeof(1) c; // int
I'm asking because isInputRange from std.range the idom from the b test:
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
{
R r; // can define a range object
if (r.empty) {} // can test for empty
r.popFront; // can invoke next
auto h = r.front; // can get the front of the range
}()));
}
This looks like a parameterless delegate to me :) Seems something akin
to __traits(compiles).
Also... The unittest contains
static assert(isInputRange!(int[]));
static assert(isInputRange!(char[]));
But arrays doesn't include these methods.. I don't understand a thing :(
They don't, but std.array imported in std.range defines the methods for
them.
--
*
*
**