www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12470] New: std.array.replace does not work with inout(char)[]

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12470

           Summary: std.array.replace does not work with inout(char)[]
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



23:13:19 CET ---
-----
import std.array;

inout(char)[] sanitize(inout(char)[] input)
{
    return input.replace("\0", " ");
}
-----

$ dmd test.d

-----
C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(1835): Error: template
std.array.replaceInto cannot deduce function from argument types
!()(Appender!(inout(char)[]), inout(char)[], string, string), candidates are:
C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(1844):       
std.array.replaceInto(E, Sink, R1, R2)(Sink sink, E[] subject, R1 from, R2 to)
if (isOutputRange!(Sink, E) && isDynamicArray!(E[]) && isForwardRange!R1 &&
isForwardRange!R2 && (hasLength!R2 || isSomeString!R2))
test.d(7): Error: template instance std.array.replace!(inout(char), string,
string) error instantiating
-----

Note that this is an internal library error.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 25 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12470


Ali Cehreli <acehreli yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli yahoo.com



Still, that code cannot be compiled, right?

inout is a wildcard that should be able to take place of const and immutable
but std.array.replace cannot work with const(char)[] nor with
immutable(char)[].

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12470




12:12:05 CET ---

 Still, that code cannot be compiled, right?
 
 inout is a wildcard that should be able to take place of const and immutable
 but std.array.replace cannot work with const(char)[] nor with
 immutable(char)[].
I thought it was supposed to allocate a new array to store the result to? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 27 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12470


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com





 Still, that code cannot be compiled, right?
 
 inout is a wildcard that should be able to take place of const and immutable
 but std.array.replace cannot work with const(char)[] nor with
 immutable(char)[].
I thought it was supposed to allocate a new array to store the result to?
Seems that way: http://dlang.org/phobos/std_array.html#replace Replace occurrences of from with to in subject. Returns a new array without changing the contents of subject, or the original array if no match is found. /---- import std.array, std.stdio; void main() { int[] c = [1, 2, 3]; c.replace([2], [4, 4]).writeln(); //[1, 4, 4, 3]; c.writeln(); //[1, 2, 3]; c.idup.replace([2], [4, 4]).writeln(); //[1, 4, 4, 3]; } //---- Ali must be thinking about "replaceInPlace" ? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 27 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12470




Sorry for the noise. :( Yes, I thought it was in-place.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 27 2014