basic_string& replace( size_type pos, size_type count,
const basic_string& str );
basic_string& replace( const_iterator first, const_iterator last,
const basic_string& str );
const basic_string& str,
const basic_string& str,
basic_string& replace( size_type pos, size_type count,
const CharT* cstr, size_type count2 );
basic_string& replace( const_iterator first, const_iterator last,
const CharT* cstr, size_type count2 );
basic_string& replace( size_type pos, size_type count,
const CharT* cstr );
basic_string& replace( const_iterator first, const_iterator last,
const CharT* cstr );
basic_string& replace( size_type pos, size_type count,
size_type count2, CharT ch );
basic_string& replace( const_iterator first, const_iterator last,
size_type count2, CharT ch );
basic_string& replace( const_iterator first, const_iterator last,
basic_string& replace( size_type pos, size_type count,
basic_string& replace( const_iterator first, const_iterator last,
basic_string& replace( size_type pos, size_type count,
const StringViewLike& t,
Replaces the characters in the range [
begin() + pos,
begin() + std::min(pos + count, size()))
or [
first,
last)
with given characters.
1,2) Those characters are replaced with str.
3)Those characters are replaced with a substring
[
pos2,
std::min(pos2 + count2, str.size()))
of
str.
4,5) Those characters are replaced with the characters in the range [
cstr,
cstr + count2)
.
If
[
cstr,
cstr + count2)
is not a
valid range, the behavior is undefined.
6,7) Those characters are replaced with the characters in the range [
cstr,
cstr + Traits::length(cstr))
.
8,9) Those characters are replaced with count2 copies of ch.
10) Those characters are replaced with the characters in the range [
first2,
last2)
as if by replace(first, last, basic_string(first2, last2, get_allocator())).
11) Those characters are replaced with the characters in ilist.
12,13)Implicitly converts
tto a string view
svas if by
std::basic_string_view<CharT, Traits> sv = t;, then those characters are replaced with the characters from
sv.
14)Implicitly converts
tto a string view
svas if by
std::basic_string_view<CharT, Traits> sv = t;, then those characters are replaced with the characters from the subview
sv.substr(pos2, count2).
If [
begin(),
first)
or [
first,
last)
is not a valid range, the behavior is undefined.
InputIt
must meet the requirements of LegacyInputIterator. [edit] Return value
*this.
[edit] ExceptionsIf the operation would cause size()
to exceed max_size()
, throws std::length_error.
If an exception is thrown for any reason, these functions have no effect (strong exception safety guarantee).
[edit] Example [edit] Defect reportsThe following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 847 C++98 there was no exception safety guarantee added strong exception safety guarantee LWG 1323 C++98 the types of first and last wereiterator
changed to const_iterator
LWG 2946 C++17 overloads (12,13) caused ambiguity in some cases avoided by making them templates [edit] See also replaces specified portion of a string with a range of characters
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4