One question about templates

bearophile bearophileHUGS at lycos.com
Wed Aug 4 19:12:24 PDT 2010


Something simpler is enough for my purposes, to tell that a type is one instantiation of Foo or not:


struct Foo(T...) {}
struct Bar(T...) {}

template IsFoo(S) {
    // ?
}

void main() {
    alias Foo!(int,int,int) S1;
    alias Foo!(float,int,int,int) S2;
    alias Bar!(float,int,int,int) S3;

    static assert(IsFoo!S1);
    static assert(IsFoo!S2);
    static assert(!IsFoo!S3);
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list