Method overloading without Type2Type

bearophile bearophileHUGS at lycos.com
Tue Apr 26 15:09:20 PDT 2011


Benjamin Thaut:

> The Type2Type template has a size of 0, thats why I'm 
> using that in the first place.

Almost. Maybe to allow addressability with pointers the minimal struct size in D is 1 byte (0-length fixed-sized arrays may require zero bytes on DMD and 1 bit on LDC):

struct Type2Type(T){
        typedef T OriginalType;
}
static assert ((Type2Type!int).sizeof == 1);
void main() {}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list