Aliasing arguments in the template parameter list of an is-expression

Ali Çehreli acehreli at yahoo.com
Tue Mar 18 10:07:01 PDT 2014


On 03/18/2014 09:02 AM, Meta wrote:
> I'd like to have the arguments of the template parameter list of an
> is-expression to be visible outside that is-expression, but I can't
> figure out a way to get an alias to them. Is something like this possible?
>
> struct Pair(alias left, alias right) {}
>
> template Left(P)
> if (is(P == Pair!(left, right), left, right)
>      && is(typeof(left) == int)
>      && is(typeof(right) == int))

Too many typeofs there. left and right are already types:

     && is(left == int)
     && is(right == int))

> {
>      //...
> }
>
> I know that I could put a constraint on the actual Pair type that left
> and right must be ints, but say I was unable to do that for some reason
> or another... Can I access that template parameter list outside of the
> first is-expression somehow?

Ali



More information about the Digitalmars-d-learn mailing list