Is it possible to check if a type is an instance of a template?
Rene Zwanenburg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 5 16:40:20 PDT 2014
On Monday, 5 May 2014 at 23:28:58 UTC, Nordlöw wrote:
>> 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.
enum IsA(A, alias B) = is(A == B!T, T);
More information about the Digitalmars-d-learn
mailing list