std::basic_string::replace
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
basic_string& replace( size_type pos, size_type count, const basic_string& str ); |
(1) | |
basic_string& replace( size_type pos, size_type count, const basic_string& str, |
(2) | |
basic_string& replace( size_type pos, size_type count, const CharT* cstr, size_type count2 ); |
(3) | |
basic_string& replace( size_type pos, size_type count, const CharT* cstr ); |
(4) | |
basic_string& replace( size_type pos, size_type count, size_type count2, CharT ch ); |
(5) | |
basic_string& replace( const_iterator first, const_iterator last, std::initializer_list<CharT> ilist ); |
(6) | (desde C++11) |
[pos, pos + count)
ou [first, last)
com uma nova seqüência.[pos, pos + count)
or [first, last)
with a new string.You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
str
stringstr
You can help to correct and verify the translation. Click here for instructions.
[pos2, pos2 + count2)
de str
ou caracteres na [first2, last2)
alcance[pos2, pos2 + count2)
of str
or characters in the range [first2, last2)
You can help to correct and verify the translation. Click here for instructions.
count2
primeiro da cadeia de caracteres apontada por cstr
count2
charcters of the character string pointed to by cstr
You can help to correct and verify the translation. Click here for instructions.
cstr
cstr
You can help to correct and verify the translation. Click here for instructions.
count2
cópias de ch
personagemcount2
copies of character ch
You can help to correct and verify the translation. Click here for instructions.
ilist
lista de inicializadorilist
You can help to correct and verify the translation. Click here for instructions.
Índice |
[editar] Parâmetros
pos | - | início da subsequência que vai ser substituído
Original: start of the substring that is going to be replaced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
count | - | comprimento da subsequência que vai ser substituído
Original: length of the substring that is going to be replaced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
first, last | - | intervalo de caracteres que vai ser substituído
Original: range of characters that is going to be replaced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
str | - | string para substituição
Original: string to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
pos2 | - | início da substring para substituir com
Original: start of the substring to replace with The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
count2 | - | número de caracteres para substituir com
Original: number of characters to replace with The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
cstr | - | ponteiro para a cadeia de caracteres a ser usado para substituição
Original: pointer to the character string to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ch | - | caráter valor a ser usado para a substituição
Original: character value to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
first2, last2 | - | intervalo de caracteres a serem usados para substituição
Original: range of characters to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
init | - | lista de inicializador com os personagens usam para substituição
Original: initializer list with the characters to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Type requirements | ||
-InputIt must meet the requirements of InputIterator .
|
[editar] Valor de retorno
*this
[editar] Exceções
std::out_of_range if pos > length()
or pos2 > str.length()
std::string::npos - 1
)std::string::npos - 1
)You can help to correct and verify the translation. Click here for instructions.
[editar] Exemplo
#include <iostream> #include <string> int main() { std::string str("The quick brown fox jumps over the lazy dog."); str.replace(10, 5, "red"); // (4) str.replace(str.begin(), str.begin() + 3, 1, 'A'); // (5) std::cout << str << '\n'; }
Saída:
A quick red fox jumps over the lazy dog.