bsl::basic_string::insert

Insert characters into this string.

Synopsis

Declared in <bslstl_string.h>

basic_string&
insert(
    size_type position,
    basic_string const& other,
    size_type sourcePosition,
    size_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 `sourcePosition + numChars > other.length(). If numChars is not specified, npos` is used. Return a reference providing modifiable access to this string. Throw out_of_range if position > length() or `sourcePosition > other.length()`.

Return Value

reference providing modifiable access to this string

Parameters

NameDescription
positionstarting index
otherstring or character sequence to compare or use
sourcePositionstarting index in the source string
numCharsnumber of characters