"Era Scarecrow" , dans le message (digitalmars.D:172568), a écrit : > On Monday, 16 July 2012 at 21:59:17 UTC, Tommi wrote: >> On Monday, 16 July 2012 at 20:22:12 UTC, Era Scarecrow wrote: >>> MyEnumType y = cast(MyEnumType) 42; //Error: wtf is 42 anyways? >> >> Like the previous fellow said, it's not an error. > > I had the impression it was illegal by the compiler; Logically > forcing an enum to an invalid state is probably undefined and > unstable (but casting with compile-time constant that's provably > correct would be different). Also I've never tried force casting > the enums, so.. Hmmm... > > I suppose 'use at your own risk' applies here.
For what it's worth, I think cast should be at your own risk, and to!MyEnumType should assert the enum is valid.