std::basic_string::basic_string
来自cppreference.com
< cpp | string | basic string
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| explicit basic_string( const Allocator& alloc = Allocator() ); |
(1) | |
| basic_string( size_type count, CharT ch, |
(2) | |
| basic_string( const basic_string& other, size_type pos, |
(3) | |
| basic_string( const CharT* s, size_type count, |
(4) | |
| basic_string( const CharT* s, const Allocator& alloc = Allocator() ); |
(5) | |
| template< class InputIt > basic_string( InputIt first, InputIt last, |
(6) | |
| basic_string( const basic_string& other ); |
(7) | |
| basic_string( const basic_string& other, const Allocator& alloc ); |
(7) | (C++11 起) |
| basic_string( basic_string&& other ) |
(8) | (C++11 起) |
| basic_string( basic_string&& other, const Allocator& alloc ); |
(8) | (C++11 起) |
| basic_string( std::initializer_list<CharT> init, const Allocator& alloc = Allocator() ); |
(9) | (C++11 起) |
从各种数据源和构造新的字符串,可以使用用户提供的分配器
1)
2) alloc.构造的字符串与字符
3) countch副本.构造字符串的一个子串
4) [pos, pos+count)other。如果所请求的子持续过去的结尾的字符串,或者如果count == npos,所得到的子字符串是[pos, size())。如果pos >= other.size(),std::out_of_range被抛出.count的第一个字符的字符串所指向的s构造的字符串。 s可以包含空字符。 s不能是NULL指针.构造的字符串以NULL结尾的字符串的内容所指向的
s。字符串的长度是由第一个空字符。 s不能是NULL指针.6) Constructs the string with the contents of the range [first, last).
7) Copy constructor. Constructs the string with the copy of the contents of other.
8) Move constructor. Constructs the string with the contents of other using move semantics.
9) Constructs the string with the contents of the initializer list init.
目录 |
[编辑] 参数
| alloc | - | |
| count | - | |
| ch | - | |
| first, last | - | |
| s | - | |
| other | - | |
| init | - | |
| 类型要求 | ||
-InputIt 必须满足 InputIterator 的要求。
| ||
[编辑] 复杂度
1) 2-4)5) linear in length of s
不变。如果
9)
alloc,并给出alloc != other.get_allocator(),则采用线性.[编辑] 示例
| 本节未完成 原因:暂无示例 |
[编辑] 另请参阅
| 为字符串赋值 (公开成员函数) | |
| 为字符串赋值 (公开成员函数) |