Why doesn't to!MyEnumType(42) work

Era Scarecrow rtcvb32 at yahoo.com
Mon Jul 16 15:21:01 PDT 2012

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.

More information about the Digitalmars-d mailing list