Chainable template mixin and opCat()

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 1 04:30:12 PDT 2015


On Monday, 1 June 2015 at 11:20:52 UTC, Per Nordlöw wrote:
> template Chainable() {
>        Chain!(typeof(this), Range) opCat(Range)(Range r) {
>            return chain(this, r);
>        }
> }

Would it suffice to restrict `opCat` as

     Chain!(typeof(this), Range) opCat(Range)(Range r)
     if (isInputRange!Range && is(CommonElementType!(typeof(this), 
Range)))

?

given that

template CommonElementType(Rs...)
{
     alias CommonElementType = CommonType!(staticMap!(ElementType, 
Rs));
}

In general, should we let `Chain` do the error checking or should 
we copy its retrictions into `opCat`s restrictions?


More information about the Digitalmars-d mailing list