Check if a type is an instantiation of a template

Posted by Pedro Lacerda on Stack Overflow See other posts from Stack Overflow or by Pedro Lacerda
Published on 2010-12-29T19:29:40Z Indexed on 2010/12/29 22:53 UTC
Read the original article Hit count: 216

Filed under:
|
|

I have structs like


struct RGBA (T) {/* ... */}
struct BMPFile (DataT) if (is(DataT == RGBA)) {/* ... */}

But is(DataT == RGBA) cannot work because DataT is a type and RGBA is a template. Instead I need check if a type is an instantiation of a template in order to declare file like


BMPFile!(RGBA!ushort) file;

In a comment @FeepingCreature showed


    struct RGBA(T) {
        alias void isRGBAStruct;
    }
    struct BMPFile (DataT) if (is(DataT.isRGBAStruct)) {}

Although to be working I have no tips on alias void isRGBAStruct.

© Stack Overflow or respective owner

Related posts about templates

Related posts about constraints