Headers

Header Files

The C++ standard specifies the entire set of header files that must be available to all hosted implementations. Actually, the word "files" is a misnomer, since the contents of the headers don't necessarily have to be in any kind of external file. The only rule is that when one #includes a header, the contents of that header become available, no matter how.

That said, in practice files are used.

There are two main types of include files: header files related to a specific version of the ISO C++ standard (called Standard Headers), and all others (TS, TR1, C++ ABI, and Extensions).

Multiple dialects of standard headers are supported, corresponding to the 1998 standard as updated for 2003, the 2011 standard, the 2014 standard, and so on.

Table 3.2, “C++ 1998 Library Headers” and Table 3.3, “C++ 1998 Library Headers for C Library Facilities” and Table 3.4, “C++ 1998 Deprecated Library Header” show the C++98/03 include files. These are available in the C++98 compilation mode, i.e. -std=c++98 or -std=gnu++98. Unless specified otherwise below, they are also available in later modes (C++11, C++14 etc).

Table 3.2. C++ 1998 Library Headers

algorithmbitsetcomplexdequeexception
fstreamfunctionaliomanipiosiosfwd
iostreamistreamiteratorlimitslist
localemapmemorynewnumeric
ostreamqueuesetsstreamstack
stdexceptstreambufstringutilitytypeinfo
valarrayvector 

Table 3.3. C++ 1998 Library Headers for C Library Facilities

cassertcerrnocctypecfloatciso646
climitsclocalecmathcsetjmpcsignal
cstdargcstddefcstdiocstdlibcstring
ctimecwcharcwctype 

The following header is deprecated and might be removed from a future C++ standard.

Table 3.4. C++ 1998 Deprecated Library Header

strstream

Table 3.5, “C++ 2011 Library Headers” and Table 3.6, “C++ 2011 Library Headers for C Library Facilities” show the C++11 include files. These are available in C++11 compilation mode, i.e. -std=c++11 or -std=gnu++11. Including these headers in C++98/03 mode may result in compilation errors. Unless specified otherwise below, they are also available in later modes (C++14 etc).

Table 3.5. C++ 2011 Library Headers

arrayatomicchronocodecvtcondition_variable
forward_listfutureinitalizer_listmutexrandom
ratioregexscoped_allocatorsystem_errorthread
tupletypeindextype_traitsunordered_mapunordered_set

Table 3.6. C++ 2011 Library Headers for C Library Facilities

ccomplexcfenvcinttypescstdaligncstdbool
cstdintctgmathcuchar 

Table 3.7, “C++ 2014 Library Header” shows the C++14 include file. This is available in C++14 compilation mode, i.e. -std=c++14 or -std=gnu++14. Including this header in C++98/03 mode or C++11 will not result in compilation errors, but will not define anything. Unless specified otherwise below, it is also available in later modes (C++17 etc).

Table 3.7. C++ 2014 Library Header

shared_mutex

Table 3.8, “C++ 2017 Library Headers” shows the C++17 include files. These are available in C++17 compilation mode, i.e. -std=c++17 or -std=gnu++17. Including these headers in earlier modes will not result in compilation errors, but will not define anything. Unless specified otherwise below, they are also available in later modes (C++20 etc).

Table 3.8. C++ 2017 Library Headers

anycharconvexecutionfilesystemmemory_resource
optionalstring_viewvariant 

Table 3.9, “C++ 2020 Library Headers” shows the C++2a include files. These are available in C++2a compilation mode, i.e. -std=c++2a or -std=gnu++2a. Including these headers in earlier modes will not result in compilation errors, but will not define anything.

Table 3.9. C++ 2020 Library Headers

bitversion

The following headers have been removed in the C++2a working draft. They are still available when using this implementation, but in future they might start to produce warnings or errors when included in C++2a mode. Programs that intend to be portable should not include them.

Table 3.10. C++ 2020 Obsolete Headers

ccomplexciso646cstdaligncstdboolctgmath

Table 3.11, “File System TS Header”, shows the additional include file define by the File System Technical Specification, ISO/IEC TS 18822. This is available in C++11 and later compilation modes. Including this header in earlier modes will not result in compilation errors, but will not define anything.

Table 3.11. File System TS Header

experimental/filesystem

Table 3.12, “Library Fundamentals TS Headers”, shows the additional include files define by the C++ Extensions for Library Fundamentals Technical Specification, ISO/IEC TS 19568. These are available in C++14 and later compilation modes. Including these headers in earlier modes will not result in compilation errors, but will not define anything.

Table 3.12. Library Fundamentals TS Headers

experimental/algorithmexperimental/anyexperimental/arrayexperimental/chronoexperimental/deque
experimental/forward_listexperimental/functionalexperimental/iteratorexperimental/listexperimental/map
experimental/memoryexperimental/memory_resourceexperimental/numericexperimental/optionalexperimental/propagate_const
experimental/randomexperimental/ratioexperimental/regexexperimental/setexperimental/source_location
experimental/stringexperimental/string_viewexperimental/system_errorexperimental/tupleexperimental/type_traits
experimental/unordered_map