On Monday, 30 November 2015 at 08:08:20 UTC, Meta wrote:
This doesn't quite work in D; you'd have to make each WhiteKey const (which is probably not a bad idea anyway if you're using it like an enum). However, it's better to just do this with plain old value-type structs. It's exactly the same as my previous code defining a WhiteKey class with an embedded enum, but using a struct instead of a class.

Thanks for the responses, everyone! Meta's is closest to one of the solutions I was thinking about and I'll probably end up going that way. It's not quite as pretty (as I would need to explicitly add the enum "id" to the struct and switch on that value instead of just the enum variable and I'll need to make sure no ids overlap), but it should work. I take it that not many others would be interested in the syntactic sugar of these like I am? :)

Reply via email to