[Issue 15800] New: std.conv.to!int does not work with ranges of char or wchar
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Mar 15 01:03:01 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15800
Issue ID: 15800
Summary: std.conv.to!int does not work with ranges of char or
wchar
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: issues.dlang at jmdavisProg.com
The following code fails to compile
import std.conv;
import std.utf;
void main()
{
auto i = to!int(byCodeUnit("10"));
auto j = to!int(byCodeUnit("10"w));
auto l = to!int(byCodeUnit("10"d));
}
Specifically, for byCodeUnit on a string or wstring, which results in a range
of char and wchar respectively, std.conv.to fails to compile. It works in the
third case, because byCodeUnit on a dstring just gives you the dstring, but the
other two fail to compile. And given the move towards using stuff like
byCodeUnit instead of relying on autodecoding in string processing in Phobos,
std.conv.to really should work with ranges of char and wchar just like it does
with ranges of dchar. Presumably, this an issue for any conversions from a
range of char or wchar, but I don't know if we want separate issues for
different types or just one for them all. Regardless, the case that I ran into
was to!int, and that definitely doesn't work right now.
--
More information about the Digitalmars-d-bugs
mailing list