Char enum conversion
Rekel
paultjeadriaanse at gmail.com
Fri Jan 1 18:11:05 UTC 2021
On Friday, 1 January 2021 at 17:59:30 UTC, Steven Schveighoffer
wrote:
> So what's happening here is that std.conv.to is treating your
> 'A' as an integer. What you are doing is really:
>
> 65.to!E.writeln; // 'A' is really a octet of 65
>
> That char/wchar/dchar are treated as a standard
> implicit-convertible integer type is one of the failings of D I
> think.
I see why that makes sense ascii wise, however, does that ruin
templating for chars?
That would seem very problematic.
> Another gotcha to watch out for, if your enum is string-based,
> there is NO WAY to use std.conv to convert from the base string
> to the enum type, it only goes by enum names.
Im unsure about what you mean here. Do you mean that an enum with
strings as assigned values cannot be converted to using any of
the assigned strings? If so, how come it does work using integers?
More information about the Digitalmars-d
mailing list