std::basic_string::basic_string

来自cppreference.com
< cpp‎ | string‎ | basic string

 
 
字符串库
null结尾的字符串
原文:
Null-terminated strings
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
字节的字符串
多字节字符串
宽字符串
原文:
Classes
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string
char_traits
 
std::basic_string
成员函数
原文:
Member functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::basic_string
basic_string::operator=
basic_string::assign
basic_string::get_allocator
元素的访问
原文:
Element access
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::at
basic_string::operator[]
basic_string::front(C++11)
basic_string::back(C++11)
basic_string::data
basic_string::c_str
迭代器
原文:
Iterators
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::begin
basic_string::cbegin

(C++11)
basic_string::end
basic_string::cend

(C++11)
basic_string::rbegin
basic_string::crbegin

(C++11)
basic_string::rend
basic_string::crend

(C++11)
容量
原文:
Capacity
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::empty
basic_string::size
basic_string::length
basic_string::max_size
basic_string::reserve
basic_string::capacity
basic_string::shrink_to_fit(C++11)
操作
原文:
Operations
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::clear
basic_string::insert
basic_string::erase
basic_string::push_back
basic_string::pop_back(C++11)
basic_string::append
basic_string::operator+=
basic_string::compare
basic_string::replace
basic_string::substr
basic_string::copy
basic_string::resize
basic_string::swap
搜索
原文:
Search
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::find
basic_string::rfind
basic_string::find_first_of
basic_string::find_first_not_of
basic_string::find_last_of
basic_string::find_last_not_of
常量
原文:
Constants
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_string::npos
非成员函数
原文:
Non-member functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
operator+
operator==
operator!=
operator<
operator>
operator<=
operator>=
swap(std::basic_string)
operator<<
operator>>
getline
stoi
stol
stoll
(C++11)
(C++11)
(C++11)
stoul
stoull
(C++11)
(C++11)
stof
stod
stold
(C++11)
(C++11)
(C++11)
to_string(C++11)
to_wstring(C++11)
Helper类
原文:
Helper classes
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
hash<std::string>
hash<std::wstring>
hash<std::u32string>
hash<std::u16string>
(C++11)
 
explicit basic_string( const Allocator& alloc = Allocator() );
(1)
basic_string( size_type count,

              CharT ch,

              const Allocator& alloc = Allocator() );
(2)
basic_string( const basic_string& other,

              size_type pos,
              size_type count = std::basic_string::npos,

              const Allocator& alloc = Allocator() );
(3)
basic_string( const CharT* s,

              size_type count,

              const Allocator& alloc = Allocator() );
(4)
basic_string( const CharT* s,
              const Allocator& alloc = Allocator() );
(5)
template< class InputIt >

basic_string( InputIt first, InputIt last,

              const Allocator& alloc = Allocator() );
(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 起)
从各种数据源和构造新的字符串,可以使用用户提供的分配器alloc.
原文:
Constructs new string from a variety of data sources and optionally using user supplied allocator alloc.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
1)
默认构造函数。构造空字符串.
原文:
Default constructor. Constructs empty string.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
2)
构造的字符串与字符countch副本.
原文:
Constructs the string with count copies of character ch.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
3)
构造字符串的一个子串[pos, pos+count)other。如果所请求的子持续过去的结尾的字符串,或者如果count == npos,所得到的子字符串是[pos, size())。如果pos >= other.size()std::out_of_range被抛出.
原文:
Constructs the string with a substring [pos, pos+count) of other. If the requested substring lasts past the end of the string, or if count == npos, the resulting substring is [pos, size()). If pos >= other.size(), std::out_of_range is thrown.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
4)
count的第一个字符的字符串所指向的s构造的字符串。 s可以包含空字符。 s不能是NULL指针.
原文:
Constructs the string with the first count characters of character string pointed to by s. s can contain null characters. s must not be a NULL pointer.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
5)
构造的字符串以NULL结尾的字符串的内容所指向的s。字符串的长度是由第一个空字符。 s不能是NULL指针.
原文:
Constructs the string with the contents of null-terminated character string pointed to by s. The length of the string is determined by the first null character. s must not be a NULL pointer.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

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 -
使用该字符串的所有内存分配的分配器
原文:
allocator to use for all memory allocations of this string
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
count -
结果字符串的大小
原文:
size of the resulting string
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
ch -
初始化字符串的值
原文:
value to initialize the string with
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
first, last -
范围内复制的字符
原文:
range to copy the characters from
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
s -
作为源use
初始化字符串的一个字符串的指针
原文:
pointer to a character string to use
as source to initialize the string with
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
other -
另一个字符串作为源使用初始化字符串
原文:
another string to use as source to initialize the string with
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
init -
初始化列表中初始化字符串
原文:
initializer list to initialize the string with
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类型要求
-
InputIt 必须满足 InputIterator 的要求。

[编辑] 复杂度

1)
不变
原文:
constant
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
2-4)
线性count
原文:
linear in count
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

5) linear in length of s

6)
firstlast之间的距离呈线性关系
原文:
linear in distance between first and last
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
7)
线性大小other
原文:
linear in size of other
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
8)
不变。如果alloc,并给出alloc != other.get_allocator(),则采用线性.
原文:
constant. If alloc is given and alloc != other.get_allocator(), then linear.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
9)
线性大小init
原文:
linear in size of init
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 示例

[编辑] 另请参阅

为字符串赋值
(公共成员函数) [edit]
为字符串赋值
(公共成员函数) [edit]