September 07, 2014 Lossless Bidirectional Enum-Conversions Mixin | ||||
---|---|---|---|---|
| ||||
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? |
September 07, 2014 Re: Lossless Bidirectional Enum-Conversions Mixin | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | 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.
|
Copyright © 1999-2021 by the D Language Foundation