Char enum conversion

Rekel paultjeadriaanse at gmail.com
Fri Jan 1 17:17:09 UTC 2021


I'm surprised char to enum conversion is currently not possible.
This, as char[] & string conversion to enum is supported.

> enum E{A, B}
> void main()
> char[] a = ['A'];
> a.to!E.writeln;
> "A".to!E.writeln;
> 'A'.to!E.writeln; // Crash
> }

The last line crashes with:
> std.conv.ConvException at C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2058): Value (A) does not match any member value of enum 'Enum'


More information about the Digitalmars-d mailing list