Safer enum casts

2011-02-01 Thread bearophile
If I have an enum of chars, and I have a variable that contains a generic char, I may want to convert the second to an instance of the first one, safely (a normal cast is enough to do it unsafely). Is it a good idea to give this purpose to to!() (this idea is currently not implemented)?

Re: Safer enum casts

2011-02-01 Thread Jesse Phillips
bearophile Wrote: If I have an enum of chars, and I have a variable that contains a generic char, I may want to convert the second to an instance of the first one, safely (a normal cast is enough to do it unsafely). Is it a good idea to give this purpose to to!() (this idea is currently

Re: Safer enum casts

2011-02-01 Thread bearophile
Jesse Phillips: I believe this is exactly what std.conv.to should do. It should be the safest and recommended way to do conversions. http://d.puremagic.com/issues/show_bug.cgi?id=5515 Bye, bearophile