Assuming a plain old bitfield-style enum like:

enum Foo {
    optionA = 1<<0;
    optionB = 1<<1;
    optionC = 1<<2;
    optionD = 1<<3;
    optionE = 1<<4;
}

Does a function already exist somewhere to take an instance of Foo and get a list of the switch names as strings?

Something kinda like:

Foo fooVar = Foo.optionB | Foo.optionD;
assert(
    DOES_THIS_FUNC_EXIST(fooVar)
        .equals(["optionB", "optionD"])
);

Seems entirely feasible, although my traits-fu is a bit rusty.

Reply via email to