template TBitMask(T){ public alias bit[T.size * 8] bitMask; private union masker{ bitMask bits; T type; } public bitMask typeToMask(in T t){ masker m; m.type = t; return m.bits; } public T maskToType(in bitMask bm){ masker m; m.bits = bm; return m.type; } }