string::replace
Replace a substring with a string.
Synopsis
string&
replace(
std::size_t pos,
std::size_t count,
string_view sv); (1)
string&
replace(
string::const_iterator first,
string::const_iterator last,
string_view sv); (2)
template<
class InputIt>
string&
replace(
string::const_iterator first,
string::const_iterator last,
InputIt first2,
InputIt last2); (3)
string&
replace(
std::size_t pos,
std::size_t count,
std::size_t count2,
char ch); (4)
string&
replace(
string::const_iterator first,
string::const_iterator last,
std::size_t count,
char ch); (5)
Description
Replaces rcount
characters starting at index pos
with those of sv
, where rcount
is std::min(count, size() - pos)
.
Exception Safety
Strong guarantee.
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. |
Template Parameters
Type | Description |
---|---|
|
The type of the iterators. |
Return Value
*this
Return Value
*this
Return Value
*this
Return Value
*this
Return Value
*this
Parameters
Name | Description |
---|---|
|
The index to replace at. |
|
The number of characters to replace. |
|
The |
|
An iterator referring to the first character to replace. |
|
An iterator one past the end of the last character to replace. |
|
An iterator referring to the first character to replace with. |
|
An iterator one past the end of the last character to replace with. |
|
The number of characters to replace with. |
|
The character to replace with. |
Exceptions
Type | Thrown On |
---|---|
|
|