Yeah, that could work: template isInputRange(R) { enum bool isInputRange = __traits(compiles, { 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 }); }
It does look nice. It would look even nicer if __traits gets renamed to meta. Stanislav Blinov Wrote: > What about __traits(compiles) ?