I have a D mixin that I would like to use to generate a switch statement (case values, in particular) for string values, but despite the fact that KeyValues has entries in it and provides the correct key values, the default case is always executed only one:
class DataStore(KeyValues...) { void stringSetData(string key, string data) { switch(key) { foreach(D; KeyValues) { mixin("case \"" ~ D.Name ~ "\": set(to!(D.Type)(data)); break;"); } default: throw new Exception("Invalid meta key"); break; } } }
I tested this with hard-coded values ββand it works as expected, so my suspicion is that I might have something wrong with my mix. How can I make this work as expected?
source share