Is there a more elegant way of testing T for multiple types?

Gary Willoughby via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 18 07:37:07 PDT 2016


Here I'm testing T is either a class or interface:

void foo(T)(T bar) if (is(T == class) || is(T == interface))
{
     ...
}

Is there a more elegant way of testing T for multiple types? 
Because it doesn't scale well if I need to add more.

I would love to use something like this:

void foo(T)(T bar) if (T in [class, interface])
{
     ...
}

Is something like this currently possible using type tuples?


More information about the Digitalmars-d-learn mailing list