[Issue 12470] std.array.replace does not work with inout(char)[]
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 27 04:43:28 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12470
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #3 from monarchdodra at 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: -------
More information about the Digitalmars-d-bugs
mailing list