View source code
Display the source code in std/array.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.array.replaceInto
Same as above, but outputs the result via OutputRange
.
If no match is found the original sink
array
is transferred to
as is.
sink
Prototype
void 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));
Example
auto arr = [1, 2, 3, 4, 5]; auto from = [2, 3]; auto into = [4, 6]; auto sink = appender!(int[])(); replaceInto(sink, arr, from, into); assert(sink.data == [1, 4, 6, 4, 5]);
Authors
Andrei Alexandrescu and Jonathan M Davis