C++标准库的头文件

C++ Standard Library headers

The interface of C++ standard library is defined by the following collection of headers.

Concepts library

<concepts>  (C++20)

Fundamental library concepts

Coroutines library

<coroutine>  (C++20)

Coroutine support library

Utilities library

<any>(C++17)

std::any class

<bitset>

std::bitset class template

<chrono>(C++11)

C++ time utilities

<compare>(C++20)

Three-way comparison operator support

<csetjmp>

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

<csignal>

Functions and macro constants for signal management

<cstdarg>

Handling of variable length argument lists

<cstddef>

Standard macros and typedefs

<cstdlib>

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

<ctime>

C-style time/date utilities

<debugging>(C++26)

Debugging library

<expected>(C++23)

std::expected class template

<functional>

Function objects, Function invocations, Bind operations and Reference wrappers

<initializer_list>(C++11)

std::initializer_list class template

<optional>(C++17)

std::optional class template

<source_location>(C++20)

Supplies means to obtain source code location

<tuple>(C++11)

std::tuple class template

<type_traits>(C++11)

Compile-time type information

<typeindex>(C++11)

std::type_index

<typeinfo>

Runtime type information utilities

<utility>

Various utility components

<variant>(C++17)

std::variant class template

<version>(C++20)

Supplies implementation-dependent library information

Dynamic memory management

<memory>

High-level memory management utilities

<memory_resource>(C++17)

Polymorphic allocators and memory resources

<new>

Low-level memory management utilities

<scoped_allocator>(C++11)

Nested allocator class

Numeric limits

<cfloat>

Limits of floating-point types

<cinttypes>(C++11)

Formatting macros, intmax_t and uintmax_t math and conversions

<climits>

Limits of integral types

<cstdint>(C++11)

Fixed-width integer types and limits of other types

<limits>

Uniform way to query properties of arithmetic types

<stdfloat>(C++23)

Optional extended floating-point types

Error handling

<cassert>

Conditionally compiled macro that compares its argument to zero

<cerrno>

Macro containing the last error number

<exception>

Exception handling utilities

<stacktrace>(C++23)

Stacktrace library

<stdexcept>

Standard exception objects

<system_error>(C++11)

Defines std::error_code, a platform-dependent error code

Strings library

<cctype>

Functions to determine the category of narrow characters

<charconv>(C++17)

std::to_chars and std::from_chars

<cstring>

Various narrow character string handling functions

<cuchar>(C++11)

C-style Unicode character conversion functions

<cwchar>

Various wide and multibyte string handling functions

<cwctype>

Functions to determine the category of wide characters

<format>(C++20)

Formatting library including std::format

<string>

std::basic_string class template

<string_view>(C++17)

std::basic_string_view class template

Containers library

<array>(C++11)

std::array container

<deque>

std::deque container

<flat_map>(C++23)

std::flat_map and std::flat_multimap container adaptors

<flat_set>(C++23)

std::flat_set and std::flat_multiset container adaptors

<forward_list>(C++11)

std::forward_list container

<list>

std::list container

<map>

std::map and std::multimap associative containers

<mdspan>(C++23)

std::mdspan view

<queue>

std::queue and std::priority_queue container adaptors

<set>

std::set and std::multiset associative containers

<span>(C++20)

std::span view

<stack>

std::stack container adaptor

<unordered_map>(C++11)

std::unordered_map and std::unordered_multimap unordered associative containers

<unordered_set>(C++11)

std::unordered_set and std::unordered_multiset unordered associative containers

<vector>

std::vector container

Iterators library

<iterator>

Range iterators

Ranges library

<generator>  (C++23)

std::generator class template

<ranges>  (C++20)

Range access, primitives, requirements, utilities and adaptors

Algorithms library

<algorithm>

Algorithms that operate on ranges

<execution>  (C++17)

Predefined execution policies for parallel versions of the algorithms

Numerics library

<bit>(C++20)

Bit manipulation functions

<cfenv>(C++11)

Floating-point environment access functions

<cmath>

Common mathematics functions

<complex>

Complex number type

<linalg>(C++26)

Basic linear algebra algorithms

<numbers>(C++20)

Math constants

<numeric>

Numeric operations on values in ranges

<random>(C++11)

Random number generators and distributions

<ratio>(C++11)

Compile-time rational arithmetic

<valarray>

Class for representing and manipulating arrays of values

Localization library

<clocale>

C localization utilities

<codecvt>(C++11)(deprecated in C++17)(removed in C++26)

Unicode conversion facilities

<locale>

Localization utilities

<text_encoding>(C++26)

Text encoding identifications

Input/output library

<cstdio>

C-style input-output functions

<fstream>

std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs

<iomanip>

Helper functions to control the format of input and output

<ios>

std::ios_base class, std::basic_ios class template and several typedefs

<iosfwd>

Forward declarations of all classes in the input/output library

<iostream>

Several standard stream objects

<istream>

std::basic_istream class template and several typedefs

<ostream>

std::basic_ostream, std::basic_iostream class templates and several typedefs

<print>(C++23)

Formatted output library including std::print

<spanstream>(C++23)

std::basic_spanstream, std::basic_ispanstream, std::basic_ospanstream class templates and typedefs

<sstream>

std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs

<streambuf>

std::basic_streambuf class template

<strstream>(deprecated in C++98)

std::strstream, std::istrstream, std::ostrstream

<syncstream>(C++20)

std::basic_osyncstream, std::basic_syncbuf, and typedefs

Filesystem library

<filesystem>  (C++17)

std::path class and supporting functions

Regular Expressions library

<regex>  (C++11)

Classes, algorithms and iterators to support regular expression processing

Atomic Operations library

<atomic>  (C++11)

Atomic operations library

Thread support library

<barrier>(C++20)

Barriers

<condition_variable>(C++11)

Thread waiting conditions

<future>(C++11)

Primitives for asynchronous computations

<hazard_pointer>(C++26)

Hazard pointers

<latch>(C++20)

Latches

<mutex>(C++11)

Mutual exclusion primitives

<rcu>(C++26)

Read-copy update mechanisms

<semaphore>(C++20)

Semaphores

<shared_mutex>(C++14)

Shared mutual exclusion primitives

<stop_token>(C++20)

Stop tokens for std::jthread

<thread>(C++11)

std::thread class and supporting functions

C compatibility headers [C兼容头文件]

对于某些 xxx.h 格式的 C 标准库头文件,C++ 标准库同时包含一个同名的头文件和另一个 cxxx 格式的头文件(所有有意义的 cxxx 头文件已在上文列出)。xxx.h 形式的头文件仅用于保持通用性。包含上述头文件的C++ 源文件,就可以使用ISO C相关功能。如果C++源文件不使用ISO C功能,则不要使用这些头文件。

For some of the C standard library headers of the form xxx.h, the C++ standard library both includes an identically-named header and another header of the form cxxx (all meaningful cxxx headers are listed above). The intended use of headers of form xxx.h is for interoperability only. It is possible that C++ source files need to include one of these headers in order to be valid ISO C. Source files that are not intended to also be valid ISO C should not use any of the C headers.

除了 complex.h 之外,C++ 标准库中的每个 xxx.h 头文件都会在全局命名空间中放置,相应的 cxxx 头文件在 std 命名空间中放置。

With the exception of complex.h, each xxx.h header included in the C++ standard library places in the global namespace each name that the corresponding cxxx header would have placed in the std namespace.

允许这些头文件在 std 名称空间中也声明相同的名称,并且允许相应的 cxxx 头文件在全局名称空间中也声明相同的名称:包含 <cstdlib> 则肯定提供 std::malloc,也可能提供 ::malloc。包含 <stdlib.h> 则肯定提供了 ::malloc,也可能提供了 std::malloc。这甚至适用于不属于 C 标准库的函数和函数重载。

These headers are allowed to also declare the same names in the std namespace, and the corresponding cxxx headers are allowed to also declare the same names in the global namespace: including <cstdlib> definitely provides std::malloc and may also provide ::malloc. Including <stdlib.h> definitely provides ::malloc and may also provide std::malloc. This applies even to functions and function overloads that are not part of C standard library.

注:xxx.h 头文件在 C++98 中已被弃用,在 C++23 中未被弃用。 对于纯 C++ 代码,不鼓励使用这些头文件,但将来不会删除。

Notes: xxx.h headers are deprecated in C++98 and undeprecated in C++23. These headers are discouraged for pure C++ code, but not subject to future removal.

<assert.h>

Behaves same as <cassert>

<ctype.h>

Behaves as if each name from <cctype> is placed in global namespace

<errno.h>

Behaves same as <cerrno>

<fenv.h>(C++11)

Behaves as if each name from <cfenv> is placed in global namespace

<float.h>

Behaves same as <cfloat>

<inttypes.h>(C++11)

Behaves as if each name from <cinttypes> is placed in global namespace

<limits.h>

Behaves same as <climits>

<locale.h>

Behaves as if each name from <clocale> is placed in global namespace

<math.h>

Behaves as if each name from <cmath> is placed in global namespace, except for names of mathematical special functions

<setjmp.h>

Behaves as if each name from <csetjmp> is placed in global namespace

<signal.h>

Behaves as if each name from <csignal> is placed in global namespace

<stdarg.h>

Behaves as if each name from <cstdarg> is placed in global namespace

<stddef.h>

Behaves as if each name from <cstddef> is placed in global namespace, except for names of std::byte and related functions

<stdint.h>(C++11)

Behaves as if each name from <cstdint> is placed in global namespace

<stdio.h>

Behaves as if each name from <cstdio> is placed in global namespace

<stdlib.h>

Behaves as if each name from <cstdlib> is placed in global namespace

<string.h>

Behaves as if each name from <cstring> is placed in global namespace

<time.h>

Behaves as if each name from <ctime> is placed in global namespace

<uchar.h>(C++11)

Behaves as if each name from <cuchar> is placed in global namespace

<wchar.h>

Behaves as if each name from <cwchar> is placed in global namespace

<wctype.h>

Behaves as if each name from <cwctype> is placed in global namespace

Special C compatibility headers

C 标准库中还有个头文件 <stdatomic.h> , 也提供了相应的声明,并定义了作为 C 关键字的 _Atomic 宏。与其他 xxx.h 头文件不同,C++里没有相对应的头文件 <cstdatomic>。

The header <stdatomic.h> declares names which are also provided in the C standard library, and defines the _Atomic macro which is a keyword in C. Unlike other xxx.h headers, corresponding <cstdatomic> is not provided.

<stdatomic.h>  (C++23)

Defines _Atomic and provides corresponding components in the C standard library

Empty C headers

头文件 <complex.h>、<ccomplex>、<tgmath.h> 和 <ctgmath> 不包含 C 标准库中的任何内容,而只是包含 C++ 标准库中的其他头文件。

The headers <complex.h>, <ccomplex>, <tgmath.h>, and <ctgmath> do not contain any content from the C standard library and instead merely include other headers from the C++ standard library.

<ccomplex>  (C++11)(deprecated in C++17)(removed in C++20)

Simply includes the header <complex>

<complex.h>  (C++11)

Simply includes the header <complex>

<ctgmath>  (C++11)(deprecated in C++17)(removed in C++20)

Simply includes the headers <complex> and <cmath>: the overloads equivalent to the contents of the C header tgmath.h are already provided by those headers

<tgmath.h>  (C++11)

Simply includes the headers <complex> and <cmath>

Meaningless C headers

头文件 <ciso646>、<cstdalign> 和 <cstdbool> 在 C++ 中毫无意义,因为它们在 C 语言中提供的宏在 C++ 中是语言关键字。

The headers <ciso646>, <cstdalign>, and <cstdbool> are meaningless in C++ because the macros they provide in C are language keywords in C++.

<ciso646>(removed in C++20)

Empty header. The macros that appear in iso646.h in C are keywords in C++

<cstdalign>(C++11)(deprecated in C++17)(removed in C++20)

Defines one compatibility macro constant

<cstdbool>(C++11)(deprecated in C++17)(removed in C++20)

Defines one compatibility macro constant

<iso646.h>

Has no effect

<stdalign.h>(C++11)

Defines one compatibility macro constant

<stdbool.h>(C++11)

Defines one compatibility macro constant

Unsupported C headers

C++ 中不包含 C 头文件 <stdatomic.h>、(直到 C++23)<stdnoreturn.h> 和 <threads.h>,也没有与之对应的 cxxx 文件。

The C headers <stdatomic.h>,(until C++23) <stdnoreturn.h>, and <threads.h> are not included in C++ and have no cxxx equivalents.

Experimental libraries [试验阶段的库]

C++ TR's/TS's 还定义了几个头文件集合。 TR (technical report),TS (technical specification),这两个都是指发布的建议阶段版本。

C++ TR's/TS's also define several collections of headers.

参考:

1,

C++ Standard Library headers - cppreference.com

  • 12
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值