std::basic_string::assign
来自cppreference.com
< cpp | string | basic string
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| basic_string& assign( size_type count, CharT ch ); |
(1) | |
| basic_string& assign( const basic_string& str ); |
(2) | |
| basic_string& assign( const basic_string& str, size_type pos, |
(3) | |
| basic_string& assign( basic_string&& str ); |
(4) | (since C++11) |
| basic_string& assign( const CharT* s, size_type count ); |
(5) | |
| basic_string& assign( const CharT* s ); |
(6) | |
| template< class InputIt > basic_string& assign( InputIt first, InputIt last ); |
(7) | |
| basic_string& assign( std::initializer_list<CharT> ilist ); |
(8) | (since C++11) |
替换的字符串的内容.
1) count的人物造型ch副本的内容替换原文:
Replaces the contents with
count copies of charactor chstr的副本的内容替换原文:
Replaces the contents with a copy of
str一个子串
4) [pos, pos+count)str的内容替换。如果所请求的子持续过去的结尾的字符串,或者如果count == npos,所得到的子字符串是[pos, size())。如果pos >= str.size(),std::out_of_range被抛出. 原文:
Replaces the contents with a substring
[pos, pos+count) of str. If the requested substring lasts past the end of the string, or if count == npos, the resulting substring is [pos, size()). If pos >= str.size(), std::out_of_range is thrown. 的
5) str使用移动语义的内容替换。 str是在不确定的状态,手术后.原文:
Replaces the contents with those of
str using move semantics. str is in undefined state after the operation.count的第一个字符的字符串所指向的s的内容替换。 s可以包含空字符.原文:
Replaces the contents with the first
count characters of character string pointed to by s. s can contain null characters.指出,
7) s以NULL结尾的字符串的内容替换。第一个空字符的字符串的长度是由. 原文:
Replaces the contents with those of null-terminated character string pointed to by
s. The length of the string is determined by the first null character. 的内容替换的字符的范围内
8) [first, last)的副本原文:
Replaces the contents with copies of the characters in the range
[first, last)与初始化列表中的内容替换
ilist.原文:
Replaces the contents with those of the initializer list
ilist.目录 |
[编辑] 参数
| count | - | 结果字符串的大小
|
| ch | - | 值来初始化字符的字符串
原文: value to initialize characters of the string with |
| first, last | - | 范围内复制的字符
|
| str | - | 字符串可以用于作为源初始化字符
原文: string to be used as source to initialize the characters with |
| s | - | 作为源use
初始化字符串的一个字符串的指针 原文: pointer to a character string to use as source to initialize the string with |
| init | - | 初始化列表中初始化字符的字符串
原文: initializer list to initialize the characters of the string with |
| 类型要求 | ||
-InputIt 必须满足 InputIterator 的要求。
| ||
[编辑] 返回值
*this
[编辑] 复杂度
1)线性
2) count线性大小
3) str线性
4) count不变。如果
5) alloc,并给出alloc != other.get_allocator(),则采用线性.原文:
constant. If
alloc is given and alloc != other.get_allocator(), then linear.线性
6) count线性大小
7) sfirst和last之间的距离呈线性关系原文:
linear in distance between
first and last线性大小
init[编辑] 示例
| 本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
| 构造 basic_string (公共成员函数) | |
| 为字符串赋值 (公共成员函数) |