成员类型 | 定义 |
---|---|
traits_type | 第一个模板参数 Traits |
value_type | Traits::char_type |
allocator_type | 第三个模板参数 Alloc |
size_type | 无符号整数类型(通常为 size_t ) |
difference_type | 有符号整数类型(通常为 ptrdiff_t ) |
reference | Allocator::reference 已弃用value_type& C++11 |
const_reference | Allocator::const_reference 已弃用const value_type& C++11 |
pointer | Allocator::pointer 已弃用std::allocator_traits<Allocator>::pointer C++11 |
const_pointer | Allocator::const_pointer 已弃用std::allocator_traits<Allocator>::const_pointer C++11 |
iterator | 随机访问迭代器 |
const_iterator | 常量随机访问迭代器 |
reverse_iterator | std::reverse_iterator<iterator> |
const_reverse_iterator | std::reverse_iterator<const_iterator> |
-
c++ string 类小结(增加c++11标准):
-
-
(constructor) 构造对象 (destructor) 析构对象 operator=
赋值操作 迭代器
begin
返回指向字符串起始位置的迭代器( iterator
)end
返回指向字符串末尾位置的迭代器 rbegin
返回指向字符串逆序起始位置的逆序迭代器( reverse_iterator
)rend
返回指向字符串逆序末尾位置的逆序迭代器 cbegin
C++11返回指向字符串起始位置的常迭代器( const_iterator
)cend
C++11返回指向字符串末尾位置的常迭代器 crbegin
C++11返回指向字符串逆序起始位置的常逆序迭代器( const_reverse_iterator
)crend
C++11返回指向字符串逆序末尾位置的常逆序迭代器 元素数量
size
返回有效字符个数 length
返回有效字符个数,跟 size
返回相同的值max_size
返回支持的最大字符个数 resize
改变有效字符个数 capacity
返回当前可使用的最大字符内存块数(即存储容器) reserve
请求改变存储容量 clear
清空字符串 empty
检测字符串是否是空的 shrink_to_fit
C++11请求移除未使用的存储空间 元素访问
operator[]
访问字符 at
访问字符 back
C++11访问最后一个字符 front
C++11访问第一个字符 修改器
operator+=
附加(Append)到字符串 append
附加到字符串 push_back
附加字符到字符串 assign
赋值内容到字符串 insert
插入到字符串 erase
从字符串中清除字符 replace
替换字符串的部分内容 swap
交换字符串对象 pop_back
C++11删除最后一个字符 字符串操作
c_str
返回 C 型字符串 data
返回字符串数据 get_allocator
获得内存分配器 copy
从字符串中拷贝字符序列 find
从字符串查找字符或字符串,返回第一次找到的位置 rfind
从从字符串查找字符或字符串,返回最后一次找到的位置 find_first_of
从字符串查找(由参数确定的)任意匹配的字符,返回第一次找到的位置 find_last_of
从字符串查找(由参数确定的)任意匹配的字符,返回最后一次找到的位置 find_first_not_of
从字符串查找(由参数确定的)任意不匹配的字符,返回第一次找到的位置 find_last_not_of
从字符串查找(由参数确定的)任意不匹配的字符,返回最后一次找到的位置 substr
产生子串 compare
比较字符串 -
npos
size_type
的最大值 -
std::operator+(std::string)
连接两个字符串或一个字符串和一个字符 operator==
operator!=
operator<
operator>
operator<=
operator>=按字典序比较两个字符串 std::swap(std::string)
特例化 std::swap
函数模板operator<<
operator>>对字符串进行流输入或输出操作 std::getline(std::string)
从流中读取一行字符 -
std::stoi
C++11将字符串转化成带符号(Signed)整数 std::stol
C++11将字符串转化成带符号整数 std::stoll
C++11将字符串转化成带符号整数 std::stoul
C++11将字符串转化成无符号(Unsigned)整数 std::stoull
C++11将字符串转化成无符号整数 std::stof
C++11将字符串转化成浮点数 std::stod
C++11将字符串转化成浮点数 std::stold
C++11将字符串转化成浮点数 std::to_string
C++11将一个整数或浮点数转化成字符串 std::to_wstring
C++11将一个整数或浮点数转化成宽字符串 std::hash<std::string>
C++11字符串的啥希(Hash)支持 std::hash<std::u16string>
C++11std::hash<std::u32string>
C++11std::hash<std::wstring>
C++11