[#BloombergLP-bslalg-ArrayPrimitives-destructiveMoveAndInsert-01]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/ArrayPrimitives.adoc[ArrayPrimitives]::destructiveMoveAndInsert
:relfileprefix: ../../../
:mrdocs:

Destructively move elements while inserting default&hyphen;initialized ones&period;

== Synopsis

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

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

== Description

Move the elements of type `allocator&lowbar;traits&lt;ALLOCATOR&gt;&colon;&colon;value&lowbar;type` in the range beginning at the specified `fromBegin` location and ending immediately before the specified `fromEnd` location into the uninitialized array beginning at the specified `toBegin` location using the specified `allocator` to supply memory (if required), inserting at the specified `position` (after translating from `fromBegin` to `toBegin`) the specified `numElements` objects initialized to default values, ensuring that the specified `fromEndPtr` points to the first uninitialized element in `&lsqb;fromBegin &period;&period; fromEnd)&rsqb;` as the elements are moved from source to destination&period; On return, the elements in the input range are invalid, i&period;e&period;, their destructors must not be called after this operation returns&period; If a constructor throws an exception during this operation, the output array is left in an uninitialized state&period; If a default constructor throws an exception, the input array is unaffected&semi; otherwise, if a (copy or move) constructor throws an exception during this operation, the input elements in the range `&lsqb;fromBegin &period;&period; &ast;fromEndPtr)&rsqb;` are left in a valid but unspecified state and the remaining portion of the input array is left in an uninitialized state&period; The behavior is undefined unless &apos;fromBegin &lt;&equals; position &lt;&equals; fromEnd&apos; and `toBegin` refers to space sufficient to hold `fromEnd &hyphen; fromBegin &plus; 1` elements&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *toBegin*
| beginning of the uninitialized destination range
| *fromEndPtr*
| loads the end of the remaining valid source range
| *fromBegin*
| beginning of the source range
| *position*
| insertion position within the source range
| *fromEnd*
| end of the source range (one past the last element)
| *numElements*
| number of default&hyphen;initialized elements to insert
| *allocator*
| allocator used to supply memory if required
|===


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