[#bsl-basic_string-0faf-insert-07]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]::insert
:relfileprefix: ../../
:mrdocs:

Insert at the specified `position` in this string the optionally specified `numChars` characters starting at the specified `sourcePosition` in the `bsl&colon;&colon;string&lowbar;view` object, obtained from the specified `other`, or the suffix of this object starting at `sourcePosition` if `sourcePosition &plus; numChars &gt; other&period;length()`&period; If `numChars` is not specified, `npos` is used&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `position &gt; length()` or `sourcePosition &gt; other&period;length()`&period; Throw `length&lowbar;error` if the length of the resulting string exceeds `max&lowbar;size()`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;string&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE&gt;
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]&
insert(
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    STRING&lowbar;VIEW&lowbar;LIKE&lowbar;TYPE const& other,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] sourcePosition,
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] numChars = npos);
----


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