std::basic_string
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   定义于头文件  <string>
  | 
||
|   template<      class CharT,   | 
(1) | |
|   namespace pmr {     template <class CharT, class Traits = std::char_traits<CharT>>  | 
(2) | (C++17 起) | 
类模板basic_string存储并操作类char对象的序列。该模板既不依赖于字符类型亦不依赖于该类型上的运算本性。运算的定义由Traits模板参数——std::char_traits的一个特化或兼容的特性类提供。
| 
 
  | 
(C++11 起) | 
std::basic_string满足具分配器容器(AllocatorAwareContainer)、顺序容器(SequenceContainer)及连续容器(ContiguousContainer) (C++17 起)的要求。
标准为常用字符类型提供数种typedef:
|   定义于头文件  
<string>  | |
| 类型 | 定义 | 
| std::string | std::basic_string<char> | 
| std::wstring | std::basic_string<wchar_t> | 
| std::u16string (C++11) | std::basic_string<char16_t> | 
| std::u32string (C++11) | std::basic_string<char32_t> | 
| std::pmr::string (C++17) | std::pmr::basic_string<char> | 
| std::pmr::wstring (C++17) | std::pmr::basic_string<wchar_t> | 
| std::pmr::u16string (C++17) | std::pmr::basic_string<char16_t> | 
| std::pmr::u32string (C++17) | std::pmr::basic_string<char32_t> | 
目录 | 
[编辑] 模板参数
| CharT | - | 字符类型 | 
| Traits | - | 指定在字符类型上操作的特性类 | 
| Allocator | - |   用于分配内部存储的分配器(Allocator)类型
 | 
[编辑] 成员类型
| 成员类型 | 定义 | 
  traits_type
 | 
  Traits
 | 
  value_type
 | 
  Traits::char_type
 | 
  allocator_type
 | 
  Allocator 
 | 
  size_type
 | 
无符号整型(通常是size_t) | 
  difference_type
 | 
有符号整型 (通常是ptrdiff_t) | 
  reference
 | 
  Allocator::reference (C++11 前)value_type& (C++11 起) 
 | 
  const_reference
 | 
  Allocator::const_reference (C++11 前)const value_type& (C++11 起) 
 | 
  pointer
 | 
  Allocator::pointer (C++11 前)std::allocator_traits<Allocator>::pointer (C++11 起)  | 
  const_pointer
 | 
  Allocator::const_pointer (C++11 前) std::allocator_traits<Allocator>::const_pointer (C++11 起)  | 
  iterator
 | 
 随机访问迭代器(RandomAccessIterator)
 | 
  const_iterator
 | 
随机访问常迭代器 | 
  reverse_iterator
 | 
std::reverse_iterator<iterator> | 
  const_reverse_iterator
 | 
std::reverse_iterator<const_iterator> | 
[编辑] 成员函数
|     (公开成员函数)  | |
|    (析构函数)  | 
  销毁字符串,解除分配内部存储,若使用它  (公开成员函数)  | 
|    为字符串赋值   (公开成员函数)  | |
|    为字符串赋值  (公开成员函数)  | |
|    返回关联的分配器   (公开成员函数)  | |
 元素访问 | |
|     访问指定位置的字符,带边界检查  (公开成员函数)  | |
|     访问指定位置的字符  (公开成员函数)  | |
|    (C++11)  | 
    (公开成员函数)  | 
|    (C++11)  | 
    (公开成员函数)  | 
|     返回一个指针,指向一个字符串的第一个字符  (公开成员函数)  | |
|     返回一个不可修改的C风格字符串  (公开成员函数)  | |
|    (C++17)  | 
  返回到整个字符串的非可修改的basic_string_view (公开成员函数)  | 
 迭代器 | |
|    (C++11)  | 
    (公开成员函数)  | 
|    (C++11)  | 
    (公开成员函数)  | 
|    (C++11)  | 
    返回一个指向字符串最后一个元素的反向迭代器    (公开成员函数)  | 
|    (C++11)  | 
    (公开成员函数)  | 
 容量 | |
|     (公开成员函数)  | |
|    返回字符数量   (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     返回当前分配的存储空间可容纳的最大字符数量   (公开成员函数)  | |
|    (C++11)  | 
    通过释放未使用的内存减少内存使用   (公开成员函数)  | 
 操作 | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|    删除字符   (公开成员函数)  | |
|     (公开成员函数)  | |
|    (C++11)  | 
    (公开成员函数)  | 
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     替换出现的每一个指定的字符  (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
 查找 | |
|    在字符串中寻找字符(串)  (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|     (公开成员函数)  | |
|    寻找字符串中任意字符最后一次缺失的位置   (公开成员函数)  | |
 常量 | |
|    [静态]  | 
    特殊值。确切的含义取决于具体情况。   (公开静态成员常量)  | 
[编辑] 非成员函数
|    连接两个字符串或者一个字符串和一个字符   (函数模板)  | |
|   按字典顺序比较两个字符串   (函数模板)  | |
|    特化 std::swap 算法  (函数模板)  | |
 输入/输出 | |
|    执行字符串的流输入和输出   (函数模板)  | |
|   从I/O流读入数据到字符串  (函数模板)  | |
 数值转换 | |
|    (C++11) (C++11) (C++11)  | 
    (函数)  | 
|    (C++11) (C++11)  | 
    (函数)  | 
|    (C++11) (C++11) (C++11)  | 
    (函数)  | 
|    (C++11)  | 
  将整值或浮点值转换成string  (函数)  | 
|    (C++11)  | 
  将整值或浮点值转换成wstring (函数)  | 
[编辑] 字面量
|   定义于内联命名空间  
std::literals::string_literals | |
|    (C++14)  | 
  将字符数组字面量转换成basic_string (函数)  | 
[编辑] 帮助类
|    (C++11) (C++11) (C++11) (C++11)  | 
    (类模板特化)  |