Thread overview | |||||
---|---|---|---|---|---|
|
June 04, 2013 [Issue 10262] New: utf.decodeFront doesn't work with a string slice | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10262 Summary: utf.decodeFront doesn't work with a string slice Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: gdkslpmq@spam4.me --- Comment #0 from Derek Rhodes <gdkslpmq@spam4.me> 2013-06-04 00:34:58 PDT --- The code import std.utf; void main() { string str = "asdf"; size_t size; decodeFront(str[1..$], size); } fails to compile, with the error test.d(8): Error: template std.utf.decodeFront does not match any function template declaration. Candidates are: /usr/include/d/std/utf.d(978): std.utf.decodeFront(S)(ref S str, out size_t numCodeUnits) if (!isSomeString!(S) && isInputRange!(S) && isSomeChar!(ElementType!(S))) /usr/include/d/std/utf.d(1012): std.utf.decodeFront(S)(ref S str, out size_t numCodeUnits) if (isSomeString!(S)) /usr/include/d/std/utf.d(1038): std.utf.decodeFront(S)(ref S str) if (isInputRange!(S) && isSomeChar!(ElementType!(S))) /usr/include/d/std/utf.d(978): Error: template std.utf.decodeFront cannot deduce template function from argument types !()(string, ulong) Casting str[1..$] to a string explicitly results in the same error. Putting the slice outside the function call, like string s2 = str[1..$]; decodeFront(s2, size); Fixed the error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 04, 2013 [Issue 10262] utf.decodeFront doesn't work with a string slice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Rhodes | http://d.puremagic.com/issues/show_bug.cgi?id=10262 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |jmdavisProg@gmx.com Resolution| |INVALID --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2013-06-04 00:50:53 PDT --- It's not supposed to work with a slice like that. It accepts arguments by ref and pops off elements from the range that it's given, so it requires that you give it an lvalue, which is what you did with string s2 = str[1..$]; decodeFront(s2, size); It accepted rvalues in 2.062, but that resulted in very inconsistent and potentially buggy behavior (depending on the type of range), so it now accepts the range by ref. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 04, 2013 [Issue 10262] utf.decodeFront doesn't work with a string slice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Rhodes | http://d.puremagic.com/issues/show_bug.cgi?id=10262 --- Comment #2 from Derek Rhodes <gdkslpmq@spam4.me> 2013-06-04 00:59:47 PDT --- Ah sorry, my mistake. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation