On Saturday, 11 May 2019 at 15:48:44 UTC, Bogdan wrote:
What would be the most straight-forward way of mapping the members of an enum to the members of another enum (one-to-one mapping) at compile time?

I'd probably have either a definition of one in terms of the other:

enum Other {
   a = First.a,
   b = First.b
}

or a helper function that just converts:

Other convert(First v) {
   final switch(v) {
     case First.a: return Other.a;
     case First.b: return Other.b;
   }
}

and then call the function and it can ctfe it. The second one is probably more practical.

Reply via email to