Implicit enum conversions are a stupid PITA
bearophile
bearophileHUGS at lycos.com
Sun Mar 28 16:03:34 PDT 2010
>The construct defines at compile-time a property for each given name.<
A costant (enum) not a property, sorry.
So this:
alias Flags!q{ A, B, C } Foo;
Becomes equivalent to:
struct Foo {
enum uint A = 1 << 0;
enum uint B = 1 << 1;
enum uint C = 1 << 2;
private uint _data;
// operators defined here, with full input tests:
// = == | |= in & &= opBool
...
}
Foo f = Foo.A | Foo.B;
Now f._data contains the or of the two flags...
Bye,
bearophile
More information about the Digitalmars-d
mailing list