enum sizes = sizesOf!(bool, short, int, long); // static use static assert(sizes[0] == 1); static assert(sizes[1] == 2); static assert(sizes[2] == 4); static assert(sizes[3] == 8); // dynamic use const i = 0; assert([sizes][i] == 1);
See Implementation