insert overloads

Synopses

Declared in <bslstl_string.h>

Insert the specified character at the specified position in this string, and return an iterator providing modifiable access to the inserted character. The behavior is undefined unless position is a valid iterator on this string.

iterator
insert(
    const_iterator position,
    char8_t character);

Insert at the specified position in this string each CHAR_TYPE object in the specified values initializer list, and return an iterator to the first newly‐inserted character. If an exception is thrown (other than by the copy constructor, move constructor, assignment operator, and move assignment operator of CHAR_TYPE), *this is unaffected. The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included).

iterator
insert(
    const_iterator position,
    std::initializer_list<char8_t> values);

Insert at the specified position in this string a copy of the specified other string, and return a reference providing modifiable access to this string. Throw out_of_range if position > length().

Insert at the specified position in this string the specified null‐terminated characterString (of length CHAR_TRAITS::length(characterString)), and return a reference providing modifiable access to this string. Throw out_of_range if position > length().

basic_string<char8_t>&
insert(
    size_type position,
    char8_t const* characterString);

Insert at the specified position in this string the bsl::string_view object, obtained from the specified other, and return a reference providing modifiable access to this string. Throw out_of_range if position > length(). Throw length_error if the length of the resulting string exceeds max_size().

template<class STRING_VIEW_LIKE_TYPE>
basic_string<char8_t>&
insert(
    size_type position,
    STRING_VIEW_LIKE_TYPE const& other);

Insert at the specified position in this string the specified numChars copies of the specified character, and return an iterator providing modifiable access to the first inserted character, or a non‐`const` copy of position if 0 == numChars. The behavior is undefined unless position is a valid iterator on this string.

iterator
insert(
    const_iterator position,
    size_type numChars,
    char8_t character);

Insert at the specified position in this string the specified numChars copies of the specified character, and return a reference providing modifiable access to this string. Throw out_of_range if position > length().

basic_string<char8_t>&
insert(
    size_type position,
    size_type numChars,
    char8_t character);

Insert at the specified position in this string the specified initial numChars characters in the specified characterString, and return a reference providing modifiable access to this string. Throw out_of_range if position > length(). The behavior is undefined unless characterString is at least numChars long.

basic_string<char8_t>&
insert(
    size_type position,
    char8_t const* characterString,
    size_type numChars);

Insert at the specified position in this string the characters in the range starting at the specified first iterator and ending right before the specified last iterator of the (template parameter) type INPUT_ITER, and return an iterator providing modifiable access to the first inserted character, or a non‐`const` copy of position if first == last. The behavior is undefined unless position is a valid iterator on this string, and first and last refer to a sequence of valid values where first is at a position at or before last.

template<class INPUT_ITER>
iterator
insert(
    const_iterator position,
    INPUT_ITER first,
    INPUT_ITER last);

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().

basic_string<char8_t>&
insert(
    size_type position,
    basic_string<char8_t> const& other,
    size_type sourcePosition,
    size_type numChars = npos);

Insert at the specified position in this string the optionally specified numChars characters starting at the specified sourcePosition in the bsl::string_view object, obtained from the specified other, or the suffix of this object 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(). Throw length_error if the length of the resulting string exceeds max_size().

template<class STRING_VIEW_LIKE_TYPE>
basic_string<char8_t>&
insert(
    size_type position,
    STRING_VIEW_LIKE_TYPE const& other,
    size_type sourcePosition,
    size_type numChars = npos);

Created with MrDocs