[#BloombergLP-bslalg-ArrayPrimitives-emplace-02] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/ArrayPrimitives.adoc[ArrayPrimitives]::emplace :relfileprefix: ../../../ :mrdocs: Emplace a newly constructed element, shifting subsequent elements. == Synopsis Declared in `<bslalg_arrayprimitives.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class ALLOCATOR, class... ARGS> static void emplace( bsl::allocator_traits<ALLOCATOR>::pointer toBegin, bsl::allocator_traits<ALLOCATOR>::pointer toEnd, ALLOCATOR allocator, ARGS&&... arguments); ---- == Description Insert a newly created `allocator_traits<ALLOCATOR>::value_type` object, constructed by forwarding the specified `allocator` (if required) and the specified (variable number of) `arguments` to the corresponding constructor of `allocator_traits<ALLOCATOR>::value_type`, into the array at the specified `toBegin` location, shifting forward the elements from `toBegin` to the specified `toEnd` location by one position. If an exception is thrown during the in‐place construction of the new object, the elements in the range `[toBegin .. toEnd)]` are unaffected; otherwise, if a (copy or move) constructor or a (copy or move) assignment operator throws an exception, then any elements created after `toEnd` are destroyed and the elements in the range `[toBegin .. toEnd )]` are left in a valid but unspecified state. The behavior is undefined unless `toBegin` refers to sufficient space to hold at least `toEnd ‐ toBegin + 1` elements. == Parameters [cols="1,4"] |=== | Name| Description | *toBegin* | insertion position within the destination array | *toEnd* | end of the populated destination range | *allocator* | allocator used to supply memory if required | *arguments* | constructor arguments forwarded to the new element |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#