[Issue 6231] New: [patch] std.conv.to: Structs with toString and isInputRange match multiple templates.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 30 11:32:02 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6231
Summary: [patch] std.conv.to: Structs with toString and
isInputRange match multiple templates.
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: patch
Severity: normal
Priority: P3
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: sandford at jhu.edu
--- Comment #0 from Rob Jacques <sandford at jhu.edu> 2011-06-30 11:27:03 PDT ---
If a struct defines a custom toString method and satisfies isInputRange, then
to!string(Struct) will match multiple toImpl templates. The solution is to add
an extra template constraint to the input range toImpl to detect structs with
custom toString methods.
[Line 194 in DMD 2.053]
T toImpl(T, S)(S s, in T leftBracket = "[", in T separator = ", ",
in T rightBracket = "]")
if (isSomeString!T && !isSomeChar!(ElementType!S) &&
(isInputRange!S || isInputRange!(Unqual!S)) )
-This is the constraint to add.
&& !(is(S == struct) && is(typeof(&S.init.toString))) )
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list