Check whether a type is a instantiated by a template struct

Jakob Ovrum jakobovrum at gmail.com
Sat Aug 11 11:56:29 PDT 2012


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 way, isn't it?

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);



More information about the Digitalmars-d-learn mailing list