[#bsl-basic_string-0f3-insert-00e] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0f3.adoc[basic_string<char32_t>]::insert :relfileprefix: ../../ :mrdocs: `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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0f3/iterator.adoc[iterator] xref:bsl/basic_string-0f3/insert-08.adoc[insert]( xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] position, char32_t character); ---- [.small]#xref:bsl/basic_string-0f3/insert-08.adoc[_» more..._]# 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). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0f3/iterator.adoc[iterator] xref:bsl/basic_string-0f3/insert-0a9.adoc[insert]( xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] position, std::initializer_list<char32_t> values); ---- [.small]#xref:bsl/basic_string-0f3/insert-0a9.adoc[_» more..._]# 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()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-09.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>] const& other); ---- [.small]#xref:bsl/basic_string-0f3/insert-09.adoc[_» more..._]# 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()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-05.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, char32_t const* characterString); ---- [.small]#xref:bsl/basic_string-0f3/insert-05.adoc[_» more..._]# 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()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-0f.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, STRING_VIEW_LIKE_TYPE const& other); ---- [.small]#xref:bsl/basic_string-0f3/insert-0f.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0f3/iterator.adoc[iterator] xref:bsl/basic_string-0f3/insert-0a6.adoc[insert]( xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] position, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars, char32_t character); ---- [.small]#xref:bsl/basic_string-0f3/insert-0a6.adoc[_» more..._]# 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()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-06d.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars, char32_t character); ---- [.small]#xref:bsl/basic_string-0f3/insert-06d.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-067.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, char32_t const* characterString, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars); ---- [.small]#xref:bsl/basic_string-0f3/insert-067.adoc[_» more..._]# 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INPUT_ITER> xref:bsl/basic_string-0f3/iterator.adoc[iterator] xref:bsl/basic_string-0f3/insert-02.adoc[insert]( xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] position, INPUT_ITER first, INPUT_ITER last); ---- [.small]#xref:bsl/basic_string-0f3/insert-02.adoc[_» more..._]# 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()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-0e.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>] const& other, xref:bsl/basic_string-0f3/size_type.adoc[size_type] sourcePosition, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-0f3/insert-0e.adoc[_» more..._]# 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()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class STRING_VIEW_LIKE_TYPE> xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/insert-007.adoc[insert]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position, STRING_VIEW_LIKE_TYPE const& other, xref:bsl/basic_string-0f3/size_type.adoc[size_type] sourcePosition, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-0f3/insert-007.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#