On Saturday, 16 April 2016 at 09:27:28 UTC, John Colvin wrote:
Very strong preference for the first. The second is so much
harder to read (not everyone is great at thinking recursively)
and also could depend on the implementation of chain if the
return type must be inferred from the body.
"iterative" just clicked in my brain, it is possible to use
foreach, using assert will not actually assert, just cause the
constraint to fail, so that another matching chain still may be
chosen.
auto chain(Ranges...)(Ranges rs)
if(is(typeof({
alias U = staticMap!(Unqual, Ranges);
alias E = staticMap!(ElementType, U);
static assert(!is(CommonType!E == void));
foreach(Range; U)
static assert(isInputRange!Range);
})))
{
...
}