1. 头文件分类(C++ 11)
类别 | 头文件 |
---|---|
算法库(Algorithms) | < algorithm > |
C库封装(C library wrappers) | <cassert>, <cctype>, <cerrno>, <cfenv>, <cfloat>, <cinttypes>, <ciso646>, <climits>, <clocale>, <cmath>, <csetjmp>, <csignal>, <cstdarg>, <cstdbool>, <cstddef>, <cstdint>, <cstdio>, <cstdlib>, <cstring>, <ctgmath>, <ctime>, <cwchar>, <cwctype> |
容器(Containers) | |
顺序容器(Sequence containers) | <array>, <deque>, <forward_list>, <list>, <vector> |
有序关联容器(Ordered associative containers) | <map>, <set> |
无序关联容器(Unordered associative containers) | <unordered_map>, <unordered_set> |
适配器容器(Adaptor containers) | <queue> <stack> |
错误和异常处理(Errors and exception handling) | <exception>, <stdexcept>, <system_error> |
输入输出和格式化(I/O and formatting) | <filesystem>, <fstream>, <iomanip>, <ios>, <iosfwd>, <iostream>, <istream>, <ostream>, <sstream>, <streambuf>, <strstream> |
迭代器(Iterators) | <iterator> |
本地化(Localization) | <codecvt>, <cvt/wbuffer>, <cvt/wstring>, <locale> |
数学(Math and numerics) | <complex>, <limits>, <numeric>, <random>, <ratio>, <valarray> |
内存管理(Memory Management) | <allocators>, <memory>, <new>, <scoped_allocator> |
多线程(Multithreading) | <atomic>, <condition_variable>, <future>, <mutex>, <shared_mutex>, <thread> |
其他工具(Other utilities) | <bitset>, <chrono>, <functional>, <initializer_list>, <tuple>, <type_traits>, <typeinfo>, <typeindex>, <utility> |
字符串和字符数据(Strings and character data) | <regex>, <string> |
C++ 标准库头文件
C++ 标准库的接口由下列头文件的汇集定义。
头文件 | 说明 |
---|---|
概念库 | |
<concepts> (C++20 起) | 基础库概念 |
协程库 | |
<coroutine> (C++20 起) | 协程支持库 |
工具库 | |
<cstdlib> | 通用工具:程序控制、动态内存分配、随机数、排序与查找 |
<csignal> | 信号管理的函数与宏常量 |
<csetjmp> | 保存到执行环境的宏,及跳到执行环境的函数 |
<cstdarg> | 变长参数列表的处理 |
<typeinfo> | 运行时类型信息工具 |
<typeindex> (C++11 起) | std::type_index |
<type_traits> (C++11 起) | 编译时类型信息 |
<bitset> | std::bitset 类模板 |
<functional> | 函数对象、函数调用、绑定操作、引用包装 |
<utility> | 多种工具组件 |
<ctime> | C 风格时间/日期工具 |
<chrono> (C++11 起) | C++ 时间工具 |
<cstddef> | 标准宏和类型定义 |
<initializer_list> (C++11 起) | std::initializer_list 类模板 |
<tuple> (C++11 起) | std::tuple 类模板 |
<any> (C++17 起) | std::any 类 |
<optional> (C++17 起) | std::optional 类模板 |
<variant> (C++17 起) | std::variant 类模板 |
<compare> (C++20 起) | 三路比较运算符支持 |
<version> (C++20 起) | 提供依赖实现的库信息 |
动态内存管理 | |
<new> | 低层内存管理工具 |
<memory> | 高层内存管理工具 |
<scoped_allocator> (C++11 起) | 嵌套分配器类 |
<memory_resource> (C++17 起) | 多态分配器及内存资源 |
数值极限 | |
<climits> | 整数类型极限 |
<cfloat> | 浮点类型极限 |
<cstdint> (C++11 起) | 定长整数及其他类型的极限 |
<cinttypes> (C++11 起) | 格式化宏、 intmax_t 及 uintmax_t 数学工具及转换 |
<limits> | 查询算术类型属性的标准化方式 |
错误处理 | |
<exception> | 异常处理工具 |
<stdexcept> | 标准异常对象 |
<cassert> | 将其参数与零比较的条件性编译宏 |
<system_error> (C++11 起) | 定义 std::error_code ,依赖平台的错误码 |
<cerrno> | 含有最近一次错误号的宏 |
<contract> (C++20 起) | 契约违规信息 |
字符串库 | |
<cctype> | 确定字符数据中所含类型的函数 |
<cwctype> | 确定宽字符数据中所含类型的函数 |
<cstring> | 多种窄字符串处理函数 |
<cwchar> | 多种宽及多字节字符串处理函数 |
<cuchar> (C++11 起) | C 风格 Unicode 字符转换函数 |
<string> | std::basic_string 类模板 |
<string_view> (C++17 起) | std::basic_string_view 类模板 |
<charconv> (C++17 起) | std::to_chars 与 std::from_chars |
容器库 | |
<array> (C++11 起) | std::array 容器 |
<vector> | std::vector 容器 |
<deque> | std::deque 容器 |
<list> | std::list 容器 |
<forward_list> (C++11 起) | std::forward_list 容器 |
<set> | std::set 及 std::multiset 关联容器 |
<map> | std::map 及 std::multimap 关联容器 |
<unordered_set> (C++11 起) | std::unordered_set 及 std::unordered_multiset |
<unordered_map> (C++11 起) | std::unordered_map 及 std::unordered_multimap |
<stack> std::stack | 容器适配器 |
<queue> | std::queue 及 std::priority_queue 容器适配器 |
<span> (C++20 起) | std::span 视图 |
迭代器库 | |
<iterator> | 范围迭代器 |
范围库 | |
<ranges> (C++20 起) | 范围访问、原始设备、要求、工具及适配器 |
算法库 | |
<algorithm> | 操作范围上的算法 |
<execution> (C++17 起) | 算法并行版本的预定义执行策略 |
数值库 | |
<cmath> | 常用数学函数 |
<complex> | 复数类型 |
<valarray> | 表示和操作值的数组的类 |
<random> (C++11 起) | 随机数生成器及分布 |
<numeric> | 容器中值的数值运算 |
<ratio> (C++11 起) | 编译时有理数算术 |
<cfenv> (C++11 起) | 浮点环境访问函数 |
<bit> (C++20 起) | 位操纵函数 |
输入/输出库 | |
<iosfwd> | 所有输入/输出库中的类的前置声明 |
<ios> | std::ios_base 类、std::basic_ios 类模板及数个 typedef |
<istream> | std::basic_istream 类模板及数个 typedef |
<ostream> | std::basic_ostream 、 std::basic_iostream 类模板及数个typedef |
<iostream> | 数个标准流对象 |
<fstream> | std::basic_fstream 、 std::basic_ifstream 、 std::basic_ofstream 类模板及数个typedef |
<sstream> | std::basic_stringstream 、 std::basic_istringstream 、 std::basic_ostringstream 类模板及数个 typedef |
<syncstream> (C++20 起) | std::basic_osyncstream 、 std::basic_syncbuf 及 typedef |
<strstream> (C++98 中弃用) | std::strstream 、 std::istrstream 、 std::ostrstream |
<iomanip> | 控制输入输出格式的帮助函数 |
<streambuf> | std::basic_streambuf 类模板 |
<cstdio> | C 风格输入输出函数 |
本地化库 | |
<locale> | 本地化工具 |
<clocale> | C 本地化工具 |
<codecvt> (C++11 起)(C++17 中弃用) | Unicode 转换设施 |
正则表达式库 | |
<regex> (C++11 起) | 支持正则表达式处理的类、算法及迭代器 |
原子操作库 | |
<atomic> (C++11 起) | 原子操作库 |
线程支持库 | |
<thread> (C++11 起) | std::thread 类及支持函数 |
<mutex> (C++11 起) | 互斥原语 |
<shared_mutex> (C++14 起) | 共享的互斥原语 |
<future> (C++11 起) | 异步计算的原语 |
<condition_variable> (C++11 起) | 线程等待条件 |
文件系统库 | |
<filesystem> (C++17 起) | std::path 类及支持函数 |
参考: