Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 25, 2014 [Issue 12470] New: std.array.replace does not work with inout(char)[] | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-03-25 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: ------- |
March 27, 2014 [Issue 12470] std.array.replace does not work with inout(char)[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | https://d.puremagic.com/issues/show_bug.cgi?id=12470 Ali Cehreli <acehreli@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |acehreli@yahoo.com --- Comment #1 from Ali Cehreli <acehreli@yahoo.com> 2014-03-26 22:51:32 PDT --- 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: ------- |
March 27, 2014 [Issue 12470] std.array.replace does not work with inout(char)[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | https://d.puremagic.com/issues/show_bug.cgi?id=12470 --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-03-27 12:12:05 CET --- (In reply to comment #1) > 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: ------- |
March 27, 2014 [Issue 12470] std.array.replace does not work with inout(char)[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | https://d.puremagic.com/issues/show_bug.cgi?id=12470 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra@gmail.com --- Comment #3 from monarchdodra@gmail.com 2014-03-27 04:43:21 PDT --- (In reply to comment #2) > (In reply to comment #1) > > 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: ------- |
March 27, 2014 [Issue 12470] std.array.replace does not work with inout(char)[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | https://d.puremagic.com/issues/show_bug.cgi?id=12470 --- Comment #4 from Ali Cehreli <acehreli@yahoo.com> 2014-03-27 10:40:12 PDT --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation