Been asked for a few times, submitting it here for posterity. enum Enum { A = 0, B, C } void main() { with (Enum) { assert (A == 0); assert (B == A+1); assert (C == B+1); } } It would be handy if the above worked. A common use case is switching on an enum: enum Enum { A = 0, B, C } void main() { Enum e; with (Enum) switch (e) { case A: case B: case C: default: break; } // the above looks much better than: switch (e) { case Enum.A: case Enum.B: case Enum.C: default: break; } }
d-bugmail@puremagic.com escribi
Works with DMD 1.055 and DMD 2.040