www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9702] New: std.string.replace for single chars too?


           Summary: std.string.replace for single chars too?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc

--- Comment #0 from bearophile_hugs eml.cc 2013-03-12 10:53:25 PDT ---
The first form is accepted but the second form is rejected:

import std.string: replace;
void main() {
    auto s1 = "hello".replace("h", "a"); // OK
    auto s2 = "hello".replace('h', 'a'); // error

DMD 2.063alpha gives:

temp.d(4): Error: no overload matches for replace(E, R1, R2)(E[] subject, R1
from, R2 to) if (isDynamicArray!(E[]) && isForwardRange!(R1) &&
isForwardRange!(R2) && (hasLength!(R2) || isSomeString!(R2)))

Maybe it's worth supporting the second form too. The advantage is possibly a
little more efficient algorithm, and more flexibility.

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 12 2013