C++ 最新的所有头文件,要经常看呀

本文介绍了C++标准库的主要组成部分,包括通用工具、信号管理、类型信息、字符串处理、容器、算法、数值计算、输入输出等核心功能,并概述了各部分的关键特性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


<cstdlib>General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search

<csignal>Functions and macro constants for signal management

<csetjmp>Macro (and function) that saves (and jumps) to an execution context

<cstdarg>Handling of variable length argument lists

<typeinfo>Runtime type information utilities

<typeindex>(since C++11)std::type_index

<type_traits>(since C++11)Compile-time type information

<bitset>std::bitset class template

<functional>Function objects, designed for use with thestandard algorithms

<utility>Various utility components

<ctime>C-style time/date utilites

<chrono>(since C++11)C++ time utilites

<cstddef>typedefs for types such as size_t, NULL and others

<initializer_list>(since C++11)std::initializer_list class template

<tuple>(since C++11)std::tuple class template
Dynamic memory management

<new>Low-level memory management utilities

<memory>Higher level memory management utilities

<scoped_allocator>(since C++11)Nested allocator class
Numeric limits

<climits>limits of integral types

<cfloat>limits of float types

<cstdint>fixed-size types andlimits of other types

<cinttypes>formatting macros,intmax_t and uintmax_t math and conversions

<limits>standardized way to query properties of fundamental types
Error handling

<exception>Exception handling utilities

<stdexcept>Standard exception objects

<cassert>Conditionally compiled macro that compares its argument to zero

<system_error>defines std::error_code, a platform-dependent error code

<cerrno>Macro containing the last error number

Strings library


<cctype>functions to determine the type contained in character data

<cwctype>functions for determining the type of wide character data

<cstring>various narrow character string handling functions

<cwstring>various wide character string handling functions

<cwchar>various wide and multibyte string handling functions

<cuchar>(since C++11)C-style Unicode character conversion functions

<string>std::basic_string class template

Containers library


<array>(since C++11)std::array container

<vector>std::vector container

<deque>std::deque container

<list>std::list container

<forward_list>(since C++11)std::forward_list container

<set>std::set andstd::multiset associative containers

<map>std::map andstd::multimap associative containers

<unordered_set>(since C++11)std::unordered_set andstd::unordered_multiset unordered associative containers

<unordered_map>(since C++11)std::unordered_map andstd::unordered_multimap unordered associative containers

<stack>std::stack container adaptor

<queue>std::queue andstd::priority_queue container adaptors

Algorithms library


<algorithm>Algorithms that operate on containers

Iterators library


<iterator>Container iterators

Numerics library


<cmath>Common mathematics functions

<complex>Complex number type

<valarray>Class for representing and manipulating arrays of values

<random>Random number generators and distributions

<numeric>Numeric operations on values in containers

<ratio>(since C++11)Compile-time rational arithmetic

<cfenv>(since C++11)Floating-point environment access functions

Input/output library


<iosfwd>forward declarations of all classes in the input/output library

<ios>std::ios_base class,std::basic_ios class template and several typedefs

<istream>std::basic_istream class template and several typedefs

<ostream>std::basic_ostream class template and several typedefs

<iostream>std::basic_iostream class template and several typedefs

<fstream>std::basic_fstream,std::basic_ifstream,std::basic_ofstream class templates and several typedefs

<sstream>std::basic_stringstream,std::basic_istringstream,std::basic_ostringstream class templates and several typedefs

<strstream>std::strstream,std::istrstream,std::ostrstream(deprecated)

<iomanip>Helper functions to control the format or input and output

<streambuf>std::basic_streambuf class template

<cstdio>C-style input-output functions

Localization library


<locale>Localization utilities

<clocale>C localization utilities

<codecvt>(since C++11)Unicode conversion facilities

Regular Expressions library


<regex>(since C++11)Classes, algorithms and iterators to support regular expression processing

Atomic Operations library


<atomic>(since C++11)Atomic operations library

Thread support library


<thread>(since C++11)std::thread class andsupporting functions

<mutex>(since C++11)mutual exclusion primitives

<future>(since C++11)primitives for asynchronous computations

<condition_variable>(since C++11)thread waiting conditions

C compatibility headers


<ciso646>empty header. The macros that appear in iso646.h in C are keywords in C++

<ccomplex>simply includes the header <complex>

<ctgmath>(since C++11)simply includes the headers <ccomplex> and <cmath>: the overloads equivalent to the contents of the C headertgmath.h are already provided by <cmath> and <complex>

<cstdalign>(since C++11)defines one compatibility macro constant

<cstdbool>(since C++11)defines one compatibility macro constant

Deprecated headers


<assert.h> (deprecated)behaves as if each name from <cassert> is placed in global namespace

<complex.h> (deprecated)behaves as if each name from <ccomplex> is placed in global namespace

<ctype.h> (deprecated)behaves as if each name from <cctype> is placed in global namespace

<errno.h> (deprecated)behaves as if each name from <cerrno> is placed in global namespace

<fenv.h> (deprecated)behaves as if each name from <cfenv> is placed in global namespace

<float.h> (deprecated)behaves as if each name from <cfloat> is placed in global namespace

<inttypes.h> (deprecated)behaves as if each name from <cinttypes> is placed in global namespace

<iso646.h> (deprecated)behaves as if each name from <ciso646> is placed in global namespace

<limits.h> (deprecated)behaves as if each name from <climits> is placed in global namespace

<locale.h> (deprecated)behaves as if each name from <clocale> is placed in global namespace

<math.h> (deprecated)behaves as if each name from <cmath> is placed in global namespace

<setjmp.h> (deprecated)behaves as if each name from <csetjmp> is placed in global namespace

<signal.h> (deprecated)behaves as if each name from <csignal> is placed in global namespace

<stdalign.h> (deprecated)behaves as if each name from <cstdalign> is placed in global namespace

<stdarg.h> (deprecated)behaves as if each name from <cstdarg> is placed in global namespace

<stdbool.h> (deprecated)behaves as if each name from <cstdbool> is placed in global namespace

<stddef.h> (deprecated)behaves as if each name from <cstddef> is placed in global namespace

<stdint.h> (deprecated)behaves as if each name from <cstdint> is placed in global namespace

<stdio.h> (deprecated)behaves as if each name from <cstdio> is placed in global namespace

<stdlib.h> (deprecated)behaves as if each name from <cstdlib> is placed in global namespace

<string.h> (deprecated)behaves as if each name from <cstring> is placed in global namespace

<tgmath.h> (deprecated)behaves as if each name from <ctgmath> is placed in global namespace

<time.h> (deprecated)behaves as if each name from <ctime> is placed in global namespace

<uchar.h> (deprecated)behaves as if each name from <cuchar> is placed in global namespace

<wchar.h> (deprecated)behaves as if each name from <cwchar> is placed in global namespace

<wctype.h> (deprecated)behaves as if each name from <cwctype> is placed in global na
<think>好的,我需要回答用户关于C++标准头文件列表的问题。首先,我要回忆C++的标准头文件,确保涵盖所有主要的头文件。根据C++标准,通常分为C兼容头文件C++特有的头文件。 对于C兼容的头文件C++版本通常以"c"开头,比如<cstdio>对应C的<stdio.h>,并且这些头文件的内容在std命名空间中。而C++特有的头文件如<iostream>、<vector>等,不需要.h后缀。 接下来,我需要列出常见的头文件,并简要说明它们的功能。例如,<iostream>用于输入输出,<vector>用于动态数组,<algorithm>提供算法函数等。同时,要提到“万能头文件”<bits/stdc++.h>,但指出其效率问题,引用户提供的引用[^1]。 需要注意格式要求:行内公式用$...$,独立公式用$$...$$,但这个问题可能涉及较少的数学表达式,更多是列表和说明。要确保使用正确的中文,结构清晰,分点列出。 然后,生成相关问题,可能包括头文件的选择、区别、优化方法等,参考用户之前的示例,比如询问各个头文件的作用、如何包含多个函数、C和C++头文件的区别等。 最后,检查引用是否正确,用户提供的引用和[^2]需要自然地插入到相关内容中,比如提到<bits/stdc++.h>时引用,提到<cstdio>时引用[^2]。 确保回答符合系统级指令,特别是引用标识的位置和格式。避免使用Markdown,但用户示例中的代码块使用了```python,但当前问题可能不需要代码块,不过用户的问题是关于头文件列表,可能用列表形式展示。 总结步骤: 1. 分两部分列出C++标准头文件:C兼容和C++特有。 2. 每个头文件简要说明功能。 3. 提到万能头文件的优缺点,引用。 4. 解释C++头文件与C的区别,引用。 5. 生成相关问题。</think>C++标准头文件可分为两类:**C兼容头文件**和**C++特有头文件**。以下是主要头文件列表及其功能说明: --- ### 一、C兼容头文件(无.h后缀,包含在`std`命名空间) 1. **`<cstdio>`** 提供输入输出功能,如`printf`、`scanf`等,对应C的`stdio.h`。 2. **`<cmath>`** 包含数学函数,如`sqrt`、`sin`、`pow`等。 3. **`<cstring>`** 提供字符串处理函数,如`strcpy`、`strlen`。 4. **`<ctime>`** 时间处理相关,如`time`、`clock`函数。 5. **`<cstdlib>`** 包含内存分配、随机数生成等,如`malloc`、`rand`。 --- ### 二、C++特有头文件 1. **`<iostream>`** 标准输入输出流,如`cin`、`cout`。 2. **`<vector>`** 实现动态数组容器`std::vector`。 3. **`<algorithm>`** 提供通用算法,如`sort`、`find`。 4. **`<string>`** C++字符串类`std::string`。 5. **`<fstream>`** 文件流操作,如`ifstream`、`ofstream`。 6. **`<memory>`** 智能指针,如`std::shared_ptr`、`std::unique_ptr`。 7. **`<thread>`** 多线程支持,如`std::thread`。 8. **`<unordered_map>`** 哈希表容器`std::unordered_map`。 --- ### 三、其他重要头文件 - **`<bits/stdc++.h>`**(非标准) 被称为“万能头文件”,包含大部分标准库,但会显著降低编译速度。 - **`<stdexcept>`** 定义标准异常类,如`std::runtime_error`。 - **`<sstream>`** 字符串流处理,如`std::stringstream`。 --- ### 注意事项 - C++头文件无`.h`后缀(如`<vector>`),而C头文件C++中以`c`开头(如`<cstdio>`)。 - 使用`using namespace std;`可省略`std::`前缀,但可能引发命名冲突。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值