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: nob...@puremagic.com
        ReportedBy: sandf...@jhu.edu


--- Comment #0 from Rob Jacques <sandf...@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: -------

Reply via email to