Is it possible to check if a type is an instance of a template?

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 5 16:28:56 PDT 2014


> template IsAFoo(T) {
>     static if (is(T t == Foo!U, U)) {
>         enum IsAFoo = true;
>     } else {
>         enum IsAFoo = false;
>     }
> }

Can we make Foo a template parameters aswell, here?

I tried this

template IsA(T, K) {
     static if (is(T t == K!U, U)) {
         enum IsA = true;
     } else {
         enum IsA = false;
     }
}

but it doesn't quite work.


More information about the Digitalmars-d-learn mailing list