The following code fail to compile:

enum KeyMod : int
{
    LCtrl  = 1 << 0,
    RCtrl  = 1 << 1,
    Ctrl   = LCtrl | RCtrl,
}

struct Flags(E)
{
public:
    BitFlags!(E, Yes.unsafe) flags;
    alias flags this;

    bool opDispatch(string name)() const
    if (__traits(hasMember, E, name))
    {
        enum e = __traits(getMember, E, name);
        return (mValue & e) != 0;
    }
}

Flags!KeyMod keys;
keys.LCtrl = true;
assert(keys.Ctrl);

Error: no property LCtrl for type Flags!(KeyMod)
Error: no property Ctrl for type Flags!(KeyMod)

Reply via email to