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

Insert characters into this string&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string]&
insert(
    xref:bsl/basic_string-0faf/size_type.adoc[size&lowbar;type] position,
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string] 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);
----

== Description

Insert at the specified `position` in this string the optionally specified `numChars` characters starting at the specified `sourcePosition` in the specified `other` string, or the suffix of `other` starting at `sourcePosition` if &grave;sourcePosition &plus; numChars &gt; other&period;length()`&period; If `numChars` is not specified, `npos&grave; is used&period; Return a reference providing modifiable access to this string&period; Throw `out&lowbar;of&lowbar;range` if `position &gt; length()` or &grave;sourcePosition &gt; other&period;length()&grave;&period;

== Return Value

reference providing modifiable access to this string

== Parameters

[cols="1,4"]
|===
| Name| Description
| *position*
| starting index
| *other*
| string or character sequence to compare or use
| *sourcePosition*
| starting index in the source string
| *numChars*
| number of characters
|===


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