I have a module:

module mymodule;

enum foo { one, three, seven};
static int[foo] mymap;

...

static this() {
        mymap = [
                one:1,
                three:3,
                seven:7
        ]
}

it works, but I want to get compile-time error if I add new value to foo enum and don't add it to initialization. How can I do it in the right way?

P.S. I always can do (after AA initialization):

foreach(m; std.traits.EnumMembers!foo)
        enforce(m in mymap, to!string(m) ~ " is absent!");

but I don't think it is elegant

Reply via email to