complete initialization of the static allocated array
Alexandr Druzhinin
drug2004 at bk.ru
Sun Aug 12 04:36:26 PDT 2012
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
More information about the Digitalmars-d-learn
mailing list