Files
Data-Structure/std-Cpp/README.MD
2025-08-28 21:17:28 +08:00

213 lines
10 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

好的下面是一份全面的《🚀C++17/C++20 标准库(`std::`)模块总览表》,涵盖**所有核心模块和功能分类**,可以作为你深入掌握 C++ 标准库(不仅仅是 STL的参考手册。
---
# 🧩 C++17/C++20 `std::` 标准库模块总览表
---
## 📦 一、容器模块Containers【STL】
| 类型 | 容器名 | 头文件 |
| ------ | ------------------------------------------------------------ | ------------------------------------ |
| 顺序容器 | `vector`, `deque`, `list`, `forward_list`, `array`, `string` | `<vector>`, `<list>`, `<array>` 等 |
| 有序关联容器 | `set`, `multiset`, `map`, `multimap` | `<set>`, `<map>` |
| 无序关联容器 | `unordered_set`, `unordered_map` 等 | `<unordered_set>`, `<unordered_map>` |
| 容器适配器 | `stack`, `queue`, `priority_queue` | `<stack>`, `<queue>` |
---
## ⚙️ 二、算法模块Algorithms【STL】
| 功能分类 | 代表算法 | 头文件 |
| ------- | ------------------------------------------------- | ------------- |
| 查找类算法 | `find`, `find_if`, `count` | `<algorithm>` |
| 修改类算法 | `remove`, `replace`, `fill` | `<algorithm>` |
| 排序/排序辅助 | `sort`, `stable_sort`, `nth_element`, `is_sorted` | `<algorithm>` |
| 复制/移动 | `copy`, `move`, `swap` | `<algorithm>` |
| 组合生成 | `next_permutation`, `prev_permutation` | `<algorithm>` |
| 数值算法 | `accumulate`, `inner_product`, `partial_sum` | `<numeric>` |
---
## 🔁 三、迭代器模块Iterators【STL】
| 功能 | 关键类型或函数 | 头文件 |
| --------- | --------------------------------------------- | ------------ |
| 迭代器标签 | `input_iterator_tag` 等 | `<iterator>` |
| 插入适配器 | `back_inserter`, `inserter`, `front_inserter` | `<iterator>` |
| 工具函数 | `begin`, `end`, `advance`, `distance` | `<iterator>` |
| C++20 范围库 | `ranges::begin`, `ranges::view` | `<ranges>` |
---
## 🧠 四、函数对象与 LambdaFunction Objects & Lambdas
| 类型/功能 | 名称 | 头文件 |
| ---------- | ------------------------------------------- | -------------- |
| 算术比较逻辑 | `std::plus`, `greater`, `logical_not` 等 | `<functional>` |
| 函数适配器 | `std::function`, `std::bind`, `std::not_fn` | `<functional>` |
| 成员绑定器 | `std::mem_fn`, `std::ref`, `cref` | `<functional>` |
| Lambda 表达式 | `[=](){}`,可捕获任意变量 | 内建语言特性 |
---
## 🧰 五、实用工具组件Utility Components
| 类型 | 名称 | 头文件 |
| ------ | ------------------------------------------- | ---------------------- |
| 元组和对 | `std::pair`, `std::tuple` | `<utility>`, `<tuple>` |
| 可选值 | `std::optional` (C++17) | `<optional>` |
| 任意类型 | `std::any` (C++17) | `<any>` |
| 多态变体类型 | `std::variant` (C++17) | `<variant>` |
| 初始化列表 | `std::initializer_list` | `<initializer_list>` |
| 类型推导工具 | `std::declval`, `std::move`, `std::forward` | `<utility>` |
---
## 🧮 六、数值和数学模块Math & Numeric
| 功能 | 名称或函数 | 头文件 |
| --------- | ------------------------------------------ | ----------- |
| 数学函数 | `abs`, `pow`, `sqrt`, `sin`, `exp`, `fmod` | `<cmath>` |
| 复杂数 | `std::complex` | `<complex>` |
| 数值算法 | `accumulate`, `inner_product` | `<numeric>` |
| 随机数生成器 | `mt19937`, `uniform_int_distribution` 等 | `<random>` |
| 比例类型 | `std::ratio` | `<ratio>` |
| 比较C++20 | `std::partial_ordering`, `strong_ordering` | `<compare>` |
---
## 🕓 七、时间与日期Time & Date
| 功能 | 名称 | 头文件 |
| ----------- | ----------------------------- | ---------- |
| 时间度量 | `std::chrono::duration` | `<chrono>` |
| 时钟 | `std::chrono::system_clock` | `<chrono>` |
| 时间点 | `std::chrono::time_point` | `<chrono>` |
| C++20 日期格式化 | `std::chrono::year_month_day` | `<chrono>` |
---
## 🧵 八、线程与并发Threading & Concurrency
| 功能 | 名称 | 头文件 |
| ----- | --------------------------------- | ---------------------- |
| 线程 | `std::thread` | `<thread>` |
| 锁 | `std::mutex`, `std::unique_lock` | `<mutex>` |
| 条件变量 | `std::condition_variable` | `<condition_variable>` |
| 原子操作 | `std::atomic` | `<atomic>` |
| 异步任务 | `std::future`, `std::async` | `<future>` |
| 屏障 | `std::barrier` (C++20) | `<barrier>` |
| 信号量 | `std::counting_semaphore` (C++20) | `<semaphore>` |
| 任务调度器 | `std::jthread` (C++20) | `<thread>` |
---
## 📚 九、输入输出流IOStreams
| 功能 | 名称 | 头文件 |
| ----- | ------------------------------------ | ------------ |
| 标准流 | `std::cin`, `std::cout`, `std::cerr` | `<iostream>` |
| 文件流 | `std::ifstream`, `std::ofstream` | `<fstream>` |
| 字符串流 | `std::stringstream`, `ostringstream` | `<sstream>` |
| 格式化输出 | `std::setw`, `std::setprecision` | `<iomanip>` |
---
## 🧬 十、类型与模板支持Type Support & Traits
| 功能 | 名称 | 头文件 |
| -------------- | ------------------------------------------------------------ | --------------- |
| 类型特征 | `std::is_same`, `is_integral`, ... | `<type_traits>` |
| 类型转换 | `std::static_cast`, `dynamic_cast` | 内建语言特性 |
| 类型工具 | `std::remove_reference`, `enable_if`, `conditional`, `decay` | `<type_traits>` |
| 模板工具 | `std::integral_constant`, `true_type`, `false_type` | `<type_traits>` |
| C++20 concepts | `std::same_as`, `std::integral` | `<concepts>` |
---
## 🧪 十一、诊断与调试Diagnostics
| 功能 | 名称 | 头文件 |
| ---- | -------------------------------------- | ---------------- |
| 异常处理 | `std::exception`, `throw`, `try` | `<exception>` |
| 断言 | `assert()` | `<cassert>` |
| 错误代码 | `std::error_code`, `std::system_error` | `<system_error>` |
| 类型信息 | `typeid`, `type_info` | `<typeinfo>` |
---
## 🧱 十二、内存与资源管理
| 功能 | 名称 | 头文件 |
| ---- | ---------------------------------------------- | ---------- |
| 智能指针 | `std::unique_ptr`, `shared_ptr`, `weak_ptr` | `<memory>` |
| 分配器 | `std::allocator`, 自定义分配器 | `<memory>` |
| 内存操作 | `std::addressof`, `std::align`, `std::launder` | `<memory>` |
| 对象管理 | `std::construct_at`, `destroy_at`C++20 | `<memory>` |
---
## 🗂️ 十三、标准支持组件
| 功能 | 名称 | 头文件 |
| ---------------- | ------------- | ----------- |
| 宏定义 | `__cplusplus` | - |
| `std::size_t` | `<cstddef>` | `<cstddef>` |
| `std::nullptr_t` | `<cstddef>` | `<cstddef>` |
---
## 📘 附录:全部头文件参考索引(常见)
```
<algorithm> 排序、查找、修改序列等算法
<array> 定长数组容器
<bitset> 位数组容器
<chrono> 时间与时钟
<cmath> 数学函数
<complex> 复数
<deque>, <list>, <vector> 动态容器
<exception>, <stdexcept> 异常类
<functional> 函数对象、bind
<iomanip> IO格式化
<iostream> 输入输出流
<iterator> 迭代器工具
<map>, <set>, <unordered_map>, <unordered_set> 关联容器
<memory> 智能指针、分配器
<mutex>, <thread>, <condition_variable> 线程并发
<numeric> 数值算法
<optional>, <variant>, <any> 可选/类型容器
<random> 随机数
<ratio> 比例
<regex> 正则表达式
<string>, <string_view> 字符串处理
<type_traits>, <concepts> 类型支持
<tuple>, <utility> 元组、pair、move、forward
```
---
## 🧭 你接下来的学习建议路线(建议阶段性掌握)
1. **基础入门**:容器 + 算法 + IO 流
2. **实用 STL**pair、tuple、function、lambda
3. **现代工具**optional、variant、any、智能指针
4. **并发开发**thread、mutex、future
5. **泛型编程**type\_traits、template、concepts
6. **大型项目支持**chrono、random、filesystem、allocator
---
## 📎 如果你需要
我可以为这份内容:
* 整理为 **PDF 文档**
* 制作为 **Markdown 笔记**
* 绘制成 **思维导图**
* 制作成 **C++ 标准库查阅表格**
你想要哪种版本?也可以选择多个,我可以立刻生成并提供下载。