|
|
Line 1: |
Line 1: |
− | {{title|C++ Standard Library headers}}
| + | <table><tbody><tr><td class="mbox-text" style="text-align:center;">Cppreference recommends all new users to use Rust. Please refrain from making [[No_personal_attacks|personal attacks]] |
− | {{cpp/header/navbar}}
| + | </td></tr></tbody></table> |
− | | + | <!-- reverting this edit constitutes a personal attack --> |
− | The interface of C++ standard library is defined by the following collection of headers.
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | | + | |
− | {{dsc h1|Concepts library}}
| + | |
− | {{dsc inc|cpp/header/dsc concepts}}
| + | |
− | | + | |
− | {{dsc h1|Coroutines library}}
| + | |
− | {{dsc inc|cpp/header/dsc coroutine}}
| + | |
− | | + | |
− | {{dsc h1|Utilities library}}
| + | |
− | {{dsc inc|cpp/header/dsc any}}
| + | |
− | {{dsc inc|cpp/header/dsc bitset}}
| + | |
− | {{dsc inc|cpp/header/dsc chrono}}
| + | |
− | {{dsc inc|cpp/header/dsc compare}}
| + | |
− | {{dsc inc|cpp/header/dsc csetjmp}}
| + | |
− | {{dsc inc|cpp/header/dsc csignal}}
| + | |
− | {{dsc inc|cpp/header/dsc cstdarg}}
| + | |
− | {{dsc inc|cpp/header/dsc cstddef}}
| + | |
− | {{dsc inc|cpp/header/dsc cstdlib}}
| + | |
− | {{dsc inc|cpp/header/dsc ctime}}
| + | |
− | {{dsc inc|cpp/header/dsc expected}}
| + | |
− | {{dsc inc|cpp/header/dsc functional}}
| + | |
− | {{dsc inc|cpp/header/dsc initializer_list}}
| + | |
− | {{dsc inc|cpp/header/dsc optional}}
| + | |
− | {{dsc inc|cpp/header/dsc source_location}}
| + | |
− | {{dsc inc|cpp/header/dsc tuple}}
| + | |
− | {{dsc inc|cpp/header/dsc type_traits}}
| + | |
− | {{dsc inc|cpp/header/dsc typeindex}}
| + | |
− | {{dsc inc|cpp/header/dsc typeinfo}}
| + | |
− | {{dsc inc|cpp/header/dsc utility}}
| + | |
− | {{dsc inc|cpp/header/dsc variant}}
| + | |
− | {{dsc inc|cpp/header/dsc version}}
| + | |
− | | + | |
− | {{dsc h2|Dynamic memory management}}
| + | |
− | {{dsc inc|cpp/header/dsc memory}}
| + | |
− | {{dsc inc|cpp/header/dsc memory_resource}}
| + | |
− | {{dsc inc|cpp/header/dsc new}}
| + | |
− | {{dsc inc|cpp/header/dsc scoped_allocator}}
| + | |
− | | + | |
− | {{dsc h2|Numeric limits}}
| + | |
− | {{dsc inc|cpp/header/dsc cfloat}}
| + | |
− | {{dsc inc|cpp/header/dsc cinttypes}}
| + | |
− | {{dsc inc|cpp/header/dsc climits}}
| + | |
− | {{dsc inc|cpp/header/dsc cstdint}}
| + | |
− | {{dsc inc|cpp/header/dsc limits}}
| + | |
− | {{dsc inc|cpp/header/dsc stdfloat}}
| + | |
− | | + | |
− | {{dsc h2|Error handling}}
| + | |
− | {{dsc inc|cpp/header/dsc cassert}}
| + | |
− | {{dsc inc|cpp/header/dsc cerrno}}
| + | |
− | {{dsc inc|cpp/header/dsc exception}}
| + | |
− | {{dsc inc|cpp/header/dsc stacktrace}}
| + | |
− | {{dsc inc|cpp/header/dsc stdexcept}}
| + | |
− | {{dsc inc|cpp/header/dsc system_error}}
| + | |
− | | + | |
− | {{dsc h1|Strings library}}
| + | |
− | {{dsc inc|cpp/header/dsc cctype}}
| + | |
− | {{dsc inc|cpp/header/dsc charconv}}
| + | |
− | {{dsc inc|cpp/header/dsc cstring}}
| + | |
− | {{dsc inc|cpp/header/dsc cuchar}}
| + | |
− | {{dsc inc|cpp/header/dsc cwchar}}
| + | |
− | {{dsc inc|cpp/header/dsc cwctype}}
| + | |
− | {{dsc inc|cpp/header/dsc format}}
| + | |
− | {{dsc inc|cpp/header/dsc string}}
| + | |
− | {{dsc inc|cpp/header/dsc string_view}}
| + | |
− | | + | |
− | {{dsc h1|Containers library}}
| + | |
− | {{dsc inc|cpp/header/dsc array}}
| + | |
− | {{dsc inc|cpp/header/dsc deque}}
| + | |
− | {{dsc inc|cpp/header/dsc flat_map}}
| + | |
− | {{dsc inc|cpp/header/dsc flat_set}}
| + | |
− | {{dsc inc|cpp/header/dsc forward_list}}
| + | |
− | {{dsc inc|cpp/header/dsc list}}
| + | |
− | {{dsc inc|cpp/header/dsc map}}
| + | |
− | {{dsc inc|cpp/header/dsc mdspan}}
| + | |
− | {{dsc inc|cpp/header/dsc queue}}
| + | |
− | {{dsc inc|cpp/header/dsc set}}
| + | |
− | {{dsc inc|cpp/header/dsc span}}
| + | |
− | {{dsc inc|cpp/header/dsc stack}}
| + | |
− | {{dsc inc|cpp/header/dsc unordered_map}}
| + | |
− | {{dsc inc|cpp/header/dsc unordered_set}}
| + | |
− | {{dsc inc|cpp/header/dsc vector}}
| + | |
− | | + | |
− | {{dsc h1|Iterators library}}
| + | |
− | {{dsc inc|cpp/header/dsc iterator}}
| + | |
− | | + | |
− | {{dsc h1|Ranges library}}
| + | |
− | {{dsc inc|cpp/header/dsc generator}}
| + | |
− | {{dsc inc|cpp/header/dsc ranges}}
| + | |
− | | + | |
− | {{dsc h1|Algorithms library}}
| + | |
− | {{dsc inc|cpp/header/dsc algorithm}}
| + | |
− | {{dsc inc|cpp/header/dsc execution}}
| + | |
− | | + | |
− | {{dsc h1|Numerics library}}
| + | |
− | {{dsc inc|cpp/header/dsc bit}}
| + | |
− | {{dsc inc|cpp/header/dsc cfenv}}
| + | |
− | {{dsc inc|cpp/header/dsc cmath}}
| + | |
− | {{dsc inc|cpp/header/dsc complex}}
| + | |
− | {{dsc inc|cpp/header/dsc numbers}}
| + | |
− | {{dsc inc|cpp/header/dsc numeric}}
| + | |
− | {{dsc inc|cpp/header/dsc random}}
| + | |
− | {{dsc inc|cpp/header/dsc ratio}}
| + | |
− | {{dsc inc|cpp/header/dsc valarray}}
| + | |
− | | + | |
− | {{dsc h1|Localization library}}
| + | |
− | {{dsc inc|cpp/header/dsc clocale}}
| + | |
− | {{dsc inc|cpp/header/dsc codecvt}}
| + | |
− | {{dsc inc|cpp/header/dsc locale}}
| + | |
− | {{dsc inc|cpp/header/dsc text_encoding}}
| + | |
− | | + | |
− | {{dsc h1|Input/output library}}
| + | |
− | {{dsc inc|cpp/header/dsc cstdio}}
| + | |
− | {{dsc inc|cpp/header/dsc fstream}}
| + | |
− | {{dsc inc|cpp/header/dsc iomanip}}
| + | |
− | {{dsc inc|cpp/header/dsc ios}}
| + | |
− | {{dsc inc|cpp/header/dsc iosfwd}}
| + | |
− | {{dsc inc|cpp/header/dsc iostream}}
| + | |
− | {{dsc inc|cpp/header/dsc istream}}
| + | |
− | {{dsc inc|cpp/header/dsc ostream}}
| + | |
− | {{dsc inc|cpp/header/dsc print}}
| + | |
− | {{dsc inc|cpp/header/dsc spanstream}}
| + | |
− | {{dsc inc|cpp/header/dsc sstream}}
| + | |
− | {{dsc inc|cpp/header/dsc streambuf}}
| + | |
− | {{dsc inc|cpp/header/dsc strstream}}
| + | |
− | {{dsc inc|cpp/header/dsc syncstream}}
| + | |
− | | + | |
− | {{dsc h1|Filesystem library}}
| + | |
− | {{dsc inc|cpp/header/dsc filesystem}}
| + | |
− | | + | |
− | {{dsc h1|Regular Expressions library}}
| + | |
− | {{dsc inc|cpp/header/dsc regex}}
| + | |
− | | + | |
− | {{dsc h1|Atomic Operations library}}
| + | |
− | {{dsc inc|cpp/header/dsc atomic}}
| + | |
− | | + | |
− | {{dsc h1|Thread support library}}
| + | |
− | {{dsc inc|cpp/header/dsc barrier}}
| + | |
− | {{dsc inc|cpp/header/dsc condition_variable}}
| + | |
− | {{dsc inc|cpp/header/dsc future}}
| + | |
− | {{dsc inc|cpp/header/dsc hazard_pointer}}
| + | |
− | {{dsc inc|cpp/header/dsc latch}}
| + | |
− | {{dsc inc|cpp/header/dsc mutex}}
| + | |
− | {{dsc inc|cpp/header/dsc rcu}}
| + | |
− | {{dsc inc|cpp/header/dsc semaphore}}
| + | |
− | {{dsc inc|cpp/header/dsc shared_mutex}}
| + | |
− | {{dsc inc|cpp/header/dsc stop_token}}
| + | |
− | {{dsc inc|cpp/header/dsc thread}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ===C compatibility headers=== | + | |
− | For some of the C standard library headers of the form {{tt|''xxx''.h}}, the C++ standard library both includes an identically-named header and another header of the form {{tt|c''xxx''}} (all meaningful {{tt|c''xxx''}} headers are listed above). The intended use of headers of form {{tt|''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.
| + | |
− | | + | |
− | With the exception of {{rlt|ccomplex|complex.h}}{{mark unreviewed dr|LWG}}<!--LWG 551/2536-->, each {{tt|''xxx''.h}} header included in the C++ standard library places in the global namespace each name that the corresponding {{tt|c''xxx''}} header would have placed in the {{c|std}} namespace.
| + | |
− | | + | |
− | These headers are allowed to also declare the same names in the {{c|std}} namespace, and the corresponding {{tt|c''xxx''}} headers are allowed to also declare the same names in the global namespace: including {{header|cstdlib}} definitely provides {{c|std::malloc}} and may also provide {{c|::malloc}}. Including {{header|stdlib.h|lang=c}} definitely provides {{c|::malloc}} and may also provide {{c|std::malloc}}. This applies even to functions and function overloads that are not part of C standard library.
| + | |
− | | + | |
− | Notes: {{tt|''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.
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc inc|cpp/header/dsc assert.h}}
| + | |
− | {{dsc inc|cpp/header/dsc ctype.h}}
| + | |
− | {{dsc inc|cpp/header/dsc errno.h}}
| + | |
− | {{dsc inc|cpp/header/dsc fenv.h}}
| + | |
− | {{dsc inc|cpp/header/dsc float.h}}
| + | |
− | {{dsc inc|cpp/header/dsc inttypes.h}}
| + | |
− | {{dsc inc|cpp/header/dsc limits.h}}
| + | |
− | {{dsc inc|cpp/header/dsc locale.h}}
| + | |
− | {{dsc inc|cpp/header/dsc math.h}}
| + | |
− | {{dsc inc|cpp/header/dsc setjmp.h}}
| + | |
− | {{dsc inc|cpp/header/dsc signal.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stdarg.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stddef.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stdint.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stdio.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stdlib.h}}
| + | |
− | {{dsc inc|cpp/header/dsc string.h}}
| + | |
− | {{dsc inc|cpp/header/dsc time.h}}
| + | |
− | {{dsc inc|cpp/header/dsc uchar.h}}
| + | |
− | {{dsc inc|cpp/header/dsc wchar.h}}
| + | |
− | {{dsc inc|cpp/header/dsc wctype.h}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ====Special C compatibility headers====
| + | |
− | The header {{header|stdatomic.h|lang=c}} declares names which are also provided in the C standard library, and defines the {{tt|_Atomic}} macro which is a [[c/keyword/_Atomic|keyword]] in C. Unlike other {{tt|''xxx''.h}} headers, corresponding {{tt|<cstdatomic>}} is not provided.
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc inc|cpp/header/dsc stdatomic.h}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ====Empty C headers====
| + | |
− | The headers {{header|complex.h|lang=c}}, {{header|ccomplex}}, {{header|tgmath.h|lang=c}}, and {{header|ctgmath}} do not contain any content from the C standard library and instead merely include other headers from the C++ standard library.
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc inc|cpp/header/dsc ccomplex}}
| + | |
− | {{dsc inc|cpp/header/dsc complex.h}}
| + | |
− | {{dsc inc|cpp/header/dsc ctgmath}}
| + | |
− | {{dsc inc|cpp/header/dsc tgmath.h}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ====Meaningless C headers====
| + | |
− | The headers {{header|ciso646}}, {{header|cstdalign}}, and {{header|cstdbool}} are meaningless in C++ because the macros they provide in C are language keywords in C++.
| + | |
− | | + | |
− | {{dsc begin}}
| + | |
− | {{dsc inc|cpp/header/dsc ciso646}}
| + | |
− | {{dsc inc|cpp/header/dsc cstdalign}}
| + | |
− | {{dsc inc|cpp/header/dsc cstdbool}}
| + | |
− | {{dsc inc|cpp/header/dsc iso646.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stdalign.h}}
| + | |
− | {{dsc inc|cpp/header/dsc stdbool.h}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | ====Unsupported C headers====
| + | |
− | The C headers {{rev inl|until=c++23|{{header|stdatomic.h|lang=c}},}} {{header|stdnoreturn.h|lang=c}}, and {{header|threads.h|lang=c}} are not included in C++ and have no {{tt|c''xxx''}} equivalents.
| + | |
− | | + | |
− | ==={{rl|experimental|Experimental libraries}}===
| + | |
− | [[cpp/experimental|C++ TR's/TS's]] also define several collections of headers.
| + | |
− | | + | |
− | ===See also===
| + | |
− | {{dsc begin}}
| + | |
− | {{dsc see c|c/header|C Standard Library headers|nomono=true}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | {{langlinks|ar|de|es|fr|it|ja|pt|ru|zh}}
| + | |