std::basic_string::insert
来自cppreference.com
                    
                                        
                    < cpp | string | basic string
                    
                                                            
                    | 
   | 
  该页由英文版wiki使用Google Translate机器翻译而来。 
 该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里.  | 
|   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) |  (until C++11)  (since C++11)  | 
|   void insert( iterator pos, size_type count, CharT ch ); iterator insert( iterator pos, size_type count, CharT ch );  | 
(7) |  (until C++11)  (since C++11)  | 
|   template< class InputIt > void insert( iterator i, InputIt first, InputIt last );  | 
(8) |  (until C++11)  (since C++11)  | 
|   iterator insert( const_iterator pos, std::initializer_list<CharT> ilist );  | 
(9) | (since C++11) | 
插入到字符串的字符
1) 
插入
countch的位置index字符的副本原文:
Inserts 
count copies of character ch at the position index2) 
s的位置index指出,通过插入NULL结尾的字符串。第一个空字符(字符串的长度是由有效地调用Traits::length(s). 原文:
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). 3) 
将
count字符的字符串所指向的s的位置index。s可以包含空字符原文:
Inserts the first 
count characters from the character string pointed to by s at the position index. s can contain null characters.4) 
插入字符串
str index原文:
Inserts string 
str at the position index5) 
将一个字符串,通过str.substr(index_str, count)的位置
index原文:
Inserts a string, obtained by str.substr(index_str, count) at the position 
index6) 
之前的字符插入字符
ch的位置所指向的pos原文:
Inserts character 
ch before the character pointed by pos7) 
插入
count字符ch的副本之前所指向的元素pos原文:
Inserts 
count copies of character ch before the element pointed to by pos8) 
插入字符的范围
[first, last) 原文:
Inserts characters from the range 
[first, last) 9) 
插入初始化列表中的元素
ilist 原文:
Inserts elements from initializer list 
ilist. 目录 | 
[编辑] 参数
| index | - |    的内容将被插入的位置 
原文:  position at which the content will be inserted  | 
| pos | - |    迭代器之前的字符将被插入 
原文:  iterator before which the characters will be inserted  | 
| ch | - |    字符插入 
 | 
| count | - |    要插入的字符数 
 | 
| s | - |    插入的字符串的指针 
原文:  pointer to the character string to insert  | 
| str | - |    要插入的字符串 
 | 
| first, last | - |    范围定义的字符插入 
 | 
| index_str | - |    的第一个字符在字符串中的 
str插入的位置原文:  position of the first character in the string  str to insert | 
| ilist | - |    初始化列表中插入字符 
原文:  initializer list to insert the characters from  | 
| 类型要求 | ||
 -InputIt 必须满足 InputIterator 的要求。
 | ||
[编辑] 返回值
1-5) *this
6-9) 
迭代器,最后插入的字符.
原文:
Iterator following the last inserted character.
[编辑] 例外
1) std::out_of_range if index > size() and std::length_error if size() + count > max_size().
2) std::out_of_range if index > size() and std::length_error if size() + Traits::length(s) > max_size().
3) std::out_of_range if index > size() and std::length_error if size() + count > max_size().
4) 
在下列条件下会抛出异常
原文:
Throws exceptions on the following conditions:
a) std::out_of_range if index > size().
b) 
std::length_errorsize() + str.size() > max_size()
ins_count的字符数,将插入原文:
std::length_error if size() + str.size() > max_size() where 
ins_count is the number of characters that will be inserted.5) 
在下列条件下会抛出异常
原文:
Throws exceptions on the following conditions:
a) std::out_of_range if index > size().
b) std::out_of_range if index_str > str.size().
c) 
std::length_errorsize() + ins_count > max_size()
ins_count的字符数,将插入原文:
std::length_error if size() + ins_count > max_size() where 
ins_count is the number of characters that will be inserted.6-9) 
(无)
[编辑] 另请参阅
|     向末尾添加字符(串)   (公共成员函数)  | |
|     向末尾添加字符   (公共成员函数)  |