C4 Engine
C4 Engine API Documentation


Defined in:  TSArray.h
Inserts an object into an array.

template <typename T> void InsertArrayElement(int32 index, T&& element);

index The location at which the object is to be inserted.
element The new element to insert into the array.
The InsertArrayElement function increases the size of an array by one, moves all of the existing elements at location index or greater up by one, and either copy-constructs or move-constructs the new element into the array using the object referenced by the element parameter, depending on whether an lvalue reference or rvalue reference is passed to the function. When the existing elements are moved, they are move-constructed in their new locations, and the old objects are destroyed.

If the index parameter is greater than or equal to the current size of the array, then the array is enlarged to the size index&#x202F;+&#x202F;1. In this case, elements between the old size and new size are default-constructed if the type of object stored in the array is a non-POD type, and the elements are left uninitialized if the type of object stored in the array is a POD type.
See Also