struct EnumToFlags(alias E) { template opDispatch(string Name) { enum opDispatch = 1 << __traits(getMember, E, Name); }; }; enum X { a,b,c } auto q = EnumtoFlags!X; auto m = q.a; with(q) { auto m = a; } a undefined. Any way to get it to work? Maybe a full blowing string mixin is needed to generate the flag enum?