Compile time mapping
    Adam D. Ruppe 
    destructionator at gmail.com
       
    Sat May 11 22:45:54 UTC 2019
    
    
  
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.
    
    
More information about the Digitalmars-d-learn
mailing list