basic_string&
insert(size_type pos,
const basic_string& str);
Effects: Equivalent to: return insert(pos, str.data(), str.size());
basic_string&
insert(size_type pos1,
const basic_string& str,
size_type pos2, size_type n = npos);
Throws:
out_of_range
if
pos1 > size()
or
pos2 > str.size(). Effects:
Determines the effective length
rlen of the string to insert as the smaller
of
n and
str.size() - pos2 and calls
insert(pos1, str.data() + pos2, rlen). basic_string& insert(size_type pos, basic_string_view<charT, traits> sv);
Effects:
Equivalent to: return insert(pos, sv.data(), sv.size());
template<class T>
basic_string& insert(size_type pos1, const T& t,
size_type pos2, size_type n = npos);
Throws:
out_of_range
if
pos1 > size()
or
pos2 > sv.size(). Effects:
Creates a variable,
sv, as if by
basic_string_view<charT, traits> sv = t. Determines the effective length
rlen of the string to assign
as the smaller of
n and
sv.size() - pos2
and calls
insert(pos1, sv.data() + pos2, rlen).Remarks:
This function shall not participate in overload resolution
unless
is_convertible_v<const T&, basic_string_view<charT, traits>>
is
true and
is_convertible_v<const T&, const charT*> is
false. basic_string&
insert(size_type pos, const charT* s, size_type n);
Requires: s points to an array of at least
n
elements of
charT. Throws: out_of_range if
pos > size() or
length_error
if
size() + n > max_size(). Effects: Replaces the string controlled by
*this with a string of
length
size() + n whose first
pos elements are a copy of
the initial elements of the original string controlled by
*this and
whose next
n elements are a copy of the elements in
s and
whose remaining elements are a copy of the remaining elements of the original
string controlled by
*this. basic_string&
insert(size_type pos, const charT* s);
Requires: s points to an array of at least
traits::length(s) + 1 elements of
charT. Effects: Equivalent to: return insert(pos, s, traits::length(s));
basic_string&
insert(size_type pos, size_type n, charT c);
Effects: Equivalent to
insert(pos, basic_string(n, c)). iterator insert(const_iterator p, charT c);
Requires:
p is a valid iterator on
*this. Effects:
Inserts a copy of
c before the character referred to by
p. Returns:
An iterator which refers to the copy of the inserted character
. iterator insert(const_iterator p, size_type n, charT c);
Requires:
p is a valid iterator on
*this. Effects:
Inserts
n copies of
c before the character referred to by
p. Returns: An iterator which refers to the copy of the first inserted character, or
p if
n == 0. template<class InputIterator>
iterator insert(const_iterator p, InputIterator first, InputIterator last);
Requires:
p is a valid iterator on
*this. [first, last)
is a valid range
. Effects:
Equivalent to
insert(p - begin(), basic_string(first, last, get_allocator())). Returns: An iterator which refers to the copy of the first inserted character, or
p if
first == last. iterator insert(const_iterator p, initializer_list<charT> il);
Effects: As if by
insert(p, il.begin(), il.end()). Returns: An iterator which refers to the copy of the first inserted character, or
p if
i1 is empty
.