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.insertInPlace
Inserts
(which must be an input range or any number of
implicitly convertible items) in stuff
at position array
.
pos
Prototypes
void insertInPlace(T, U...)( T[] array, size_t pos, U stuff ) if (!isSomeString!(T[]) && allSatisfy!(isInputRangeOrConvertible!T, U) && U.length > 0); void insertInPlace(T, U...)( T[] array, size_t pos, U stuff ) if (isSomeString!(T[]) && allSatisfy!(isCharOrStringOrDcharRange, U));
Example
int[] a = [ 1, 2, 3, 4 ]; a.insertInPlace(2, [ 1, 2 ]); assert(a == [ 1, 2, 1, 2, 3, 4 ]); a.insertInPlace(3, 10u, 11); assert(a == [ 1, 2, 1, 10, 11, 2, 3, 4]);
Authors
Andrei Alexandrescu and Jonathan M Davis