typeof and block statements
simendsjo
simen.endsjo at pandavre.com
Thu Aug 12 06:13:54 PDT 2010
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
}()));
}
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 :(
More information about the Digitalmars-d-learn
mailing list