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.replaceInPlace
Replaces elements from
with indices ranging array
from
(inclusive) from
to
(exclusive) with the range to
. Expands or
shrinks the stuff
array
as needed.
Prototype
void replaceInPlace(T, Range)( T[] array, size_t from, size_t to, Range stuff ) if (is(typeof(replace(array, from, to, stuff))));
Example
int[] a = [1, 4, 5]; replaceInPlace(a, 1u, 2u, [2, 3, 4]); assert(a == [1, 2, 3, 4, 5]); replaceInPlace(a, 1u, 2u, cast(int[])[]); assert(a == [1, 3, 4, 5]); replaceInPlace(a, 1u, 3u, a[2 .. 4]); assert(a == [1, 4, 5, 5]);
Authors
Andrei Alexandrescu and Jonathan M Davis