[#BloombergLP-bslalg-ArrayPrimitives-insert-0f]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/ArrayPrimitives.adoc[ArrayPrimitives]::insert
:relfileprefix: ../../../
:mrdocs:

Insert a source range, shifting subsequent elements&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;arrayprimitives&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class ALLOCATOR,
    class FWD&lowbar;ITER,
    class SENTINEL&gt;
static
void
insert(
    bsl::allocator&lowbar;traits&lt;ALLOCATOR&gt;::pointer toBegin,
    bsl::allocator&lowbar;traits&lt;ALLOCATOR&gt;::pointer toEnd,
    FWD&lowbar;ITER fromBegin,
    SENTINEL fromEnd,
    xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size&lowbar;type] numElements,
    ALLOCATOR allocator);
----

== Description

Insert the specified `numElements` from the range starting at the specified `fromBegin` of (template parameter) `FWD&lowbar;ITER` type (or template parameter `SOURCE&lowbar;TYPE &ast;`) and ending immediately before the specified `fromEnd` sentinels or iterators of (template parameter) `SENTINEL` type (or template parameter `SOURCE&lowbar;TYPE &ast;`), into the array of elements of type given by the `allocator&lowbar;traits` class template for (template parameter) `ALLOCATOR`, starting at the specified `toBegin` address, shifting forward the elements in the array by `numElements` positions&period; The behavior is undefined unless the destination array contains `numElements` uninitialized elements after `toEnd`, `numElements` is the distance between `fromBegin` and `fromEnd`, and the input array and the destination array do not overlap&period; If a copy constructor or assignment operator throws an exception, then any elements created after `toEnd` are destroyed and the elements in the range `&lsqb; toBegin, toEnd )&rsqb;` will have valid but unspecified values&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *toBegin*
| insertion position within the destination array
| *toEnd*
| end of the populated destination range
| *fromBegin*
| beginning of the source range to insert
| *fromEnd*
| end of the source range to insert
| *numElements*
| number of elements to insert from the source range
| *allocator*
| allocator used to supply memory if required
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
