with not working wtih BitFlags

Jot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 19 18:09:49 PST 2017




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?





More information about the Digitalmars-d-learn mailing list