digitalmars.D.learn - Lossless Bidirectional Enum-Conversions Mixin
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (11/11) Sep 07 2014 Have anybody come up with some mixin magic that given
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (15/20) Sep 07 2014 The enumeration names must of course be given aswell:
Have anybody come up with some mixin magic that given enum A { x,y,z } enum B { a,b,c } and call to a mixin BidirectionalEnums( "x", "a", "y", "b", "z", "c", ); generates two to!Enum overloads that implement bidirectional (lossless) conversion rules between A and B?
Sep 07 2014
On Sunday, 7 September 2014 at 17:22:38 UTC, Nordlöw wrote:BidirectionalEnums( "x", "a", "y", "b", "z", "c", );The enumeration names must of course be given aswell: BidirectionalEnums2( "A", "B", "x", "a", ... ); and two specifies the number of enums involved. We could of course also use BidirectionalEnums( tuple("A", "B"), tuple("x", "a"), ... ); for more verbosity.
Sep 07 2014