std::basic_string::insert
Материал из cppreference.com
< cpp | string | basic string
![]() |
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& insert( size_type index, size_type count, CharT ch ); |
(1) | |
basic_string& insert( size_type index, const CharT* s ); |
(2) | |
basic_string& insert( size_type index, const CharT* s, size_type count ); |
(3) | |
basic_string& insert( size_type index, const basic_string& str ); |
(4) | |
basic_string& insert( size_type index, const basic_string& str, size_type index_str, size_type count ); |
(5) | |
iterator insert( iterator pos, CharT ch ); iterator insert( const_iterator pos, CharT ch ); |
(6) | (до C++11) (начиная с C++11) |
void insert( iterator pos, size_type count, CharT ch ); iterator insert( iterator pos, size_type count, CharT ch ); |
(7) | (до C++11) (начиная с C++11) |
template< class InputIt > void insert( iterator i, InputIt first, InputIt last ); |
(8) | (до C++11) (начиная с C++11) |
iterator insert( const_iterator pos, std::initializer_list<CharT> ilist ); |
(9) | (начиная с C++11) |
Вставка символов в строке:
Original:
Inserts characters into the string:
The text has been machine-translated via Google Translate.
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.
1)
Вставки
count
копии характер ch
в положении index
Original:
Inserts
count
copies of character ch
at the position index
The text has been machine-translated via Google Translate.
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.
2)
Вставки нулем строку символов, на которую указывает
s
в положении index
. Длина строки определяется первым символом NULL (фактически звонки Traits::length(s). Original:
Inserts null-terminated character string pointed to by
s
at the position index
. The length of the string is determined by the first null character (effectively calls Traits::length(s). The text has been machine-translated via Google Translate.
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.
3)
Вставки первые символы
count
из символьной строки, на которую указывает s
в положении index
. s
может содержать нулевые символы.Original:
Inserts the first
count
characters from the character string pointed to by s
at the position index
. s
can contain null characters.The text has been machine-translated via Google Translate.
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.
4)
Вставляет строку
str
в положении index
Original:
Inserts string
str
at the position index
The text has been machine-translated via Google Translate.
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.
5)
Вставляет строку, полученных str.substr(index_str, count) в положении
index
Original:
Inserts a string, obtained by str.substr(index_str, count) at the position
index
The text has been machine-translated via Google Translate.
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.
6)
Вставляет символ
ch
перед символом, на который указывает pos
Original:
Inserts character
ch
before the character pointed by pos
The text has been machine-translated via Google Translate.
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.
7)
Вставки
count
копии характер ch
перед элементом, на который указывает pos
Original:
Inserts
count
copies of character ch
before the element pointed to by pos
The text has been machine-translated via Google Translate.
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.
8)
Вставка символов из диапазона
[first, last)
Original:
Inserts characters from the range
[first, last)
The text has been machine-translated via Google Translate.
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.
9)
Вставка элементов из списка инициализации
ilist
. Original:
Inserts elements from initializer list
ilist
. The text has been machine-translated via Google Translate.
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.
Содержание |
[править] Параметры
index | - | положение, при котором содержимое будет вставлено
Original: position at which the content will be inserted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
pos | - | Итератор, перед которой символы будут вставлены
Original: iterator before which the characters will be inserted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ch | - | характер для вставки
Original: character to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
count | - | Количество символов для вставки
Original: number of characters to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
s | - | Указатель на строку символов для вставки
Original: pointer to the character string to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
str | - | Строка для вставки
Original: string to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
first, last | - | Диапазон определении символа для вставки
Original: range defining characters to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
index_str | - | Позиция первого символа в строке
str вставитьOriginal: position of the first character in the string str to insertThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ilist | - | инициализатор список, чтобы вставить символы
Original: initializer list to insert the characters from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Требования, накладываемые на типы | ||
-InputIt должен соответствовать требованиям InputIterator .
|
[править] Возвращаемое значение
1-5) *this
6-9)
Iterator после последнего вставленного символа.
Original:
Iterator following the last inserted character.
The text has been machine-translated via Google Translate.
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.
[править] Исключения
2) std::out_of_range if index > size() and std::length_error if size() + Traits::length(s) > max_size().
4)
Выдает исключение, на следующих условиях:
Original:
Throws exceptions on the following conditions:
The text has been machine-translated via Google Translate.
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.
b)
std::length_error если size() + str.size() > max_size() где
ins_count
является количество символов, которое будет вставлено.Original:
std::length_error if size() + str.size() > max_size() where
ins_count
is the number of characters that will be inserted.The text has been machine-translated via Google Translate.
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.
5)
Выдает исключение, на следующих условиях:
Original:
Throws exceptions on the following conditions:
The text has been machine-translated via Google Translate.
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.
c)
std::length_error если size() + ins_count > max_size() где
ins_count
является количество символов, которое будет вставлено.Original:
std::length_error if size() + ins_count > max_size() where
ins_count
is the number of characters that will be inserted.The text has been machine-translated via Google Translate.
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.
6-9)
(Нет)
Original:
(none)
The text has been machine-translated via Google Translate.
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.
[править] См. также
добавляет символы до конца Original: appends characters to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
добавляет характер до конца Original: appends a character to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) |