On Tuesday, 27 August 2013 at 14:13:25 UTC, Chris wrote:
Another drawback is that ranges demand a lot of boilerplate
code. If properly implemented, there is a lot of code you have
to write over and over again such as
if (isInputRange!Range && isInputRange!(ElementType!Range) &&
is(ElementType!(ElementType!Range) == MyType))
I don't know if this could possibly be reduced. Or maybe it's
just my lack of experience.
If you've got a lot of repeated template constraints, simply
moving them out in to a separate template can be useful e.g.
template isIRofIRofT(Range, T)
{
enum isRoRoT = isInputRange!Range
&& isInputRange!(ElementType!Range)
&& is(ElementType!(ElementType!Range) == T);
}
if(isIRofIRofT!(Range, MyType))