Check whether a type is a instantiated by a template struct

2012-08-11 Thread Henning Pohl
So the struct is defined as: struct S(T) { } template isS(T) { // ... } static assert(isS(S!float)); static assert(!isS(float)); There may be some nasty ways using fullQualifiedName!T and so on but I guess there is a better way, isn't it?

Re: Check whether a type is a instantiated by a template struct

2012-08-11 Thread Jakob Ovrum
On Saturday, 11 August 2012 at 18:51:36 UTC, Henning Pohl wrote: So the struct is defined as: struct S(T) { } template isS(T) { // ... } static assert(isS(S!float)); static assert(!isS(float)); There may be some nasty ways using fullQualifiedName!T and so on but I guess there is a better

Re: Check whether a type is a instantiated by a template struct

2012-08-11 Thread Chris Cain
On Saturday, 11 August 2012 at 18:56:30 UTC, Jakob Ovrum wrote: struct S(T) {} template isS(T : S!U, U) { enum isS = true; } template isS(T) { enum isS = false; } static assert(isS!(S!float)); static assert(!isS!float); Same idea, but doing it with just one template and using static

Re: Check whether a type is a instantiated by a template struct

2012-08-11 Thread Henning Pohl
On Saturday, 11 August 2012 at 19:06:22 UTC, Chris Cain wrote: Same idea, but doing it with just one template and using static ifs... struct S(T) {} template isS(T) { static if(is(T _ : S!U, U)) enum isS = true; else enum isS = false; } static assert(isS!(S!float));

Re: Check whether a type is a instantiated by a template struct

2012-08-11 Thread Jakob Ovrum
On Saturday, 11 August 2012 at 19:06:22 UTC, Chris Cain wrote: Same idea, but doing it with just one template and using static ifs... struct S(T) {} template isS(T) { static if(is(T _ : S!U, U)) enum isS = true; else enum isS = false; } static assert(isS!(S!float)); st