C++ Standard Library headers - cppreference.com

(Redirected from

cpp/headers

)

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

<cstdlib>

General purpose utilities:

program control

,

dynamic memory allocation

,

random numbers

,

sort and search

[edit]

<execution>

(C++17)

Predefined execution policies for parallel versions of the algorithms and execution control components(since C++26)

[edit]

Language support library

<cfloat>

Limits of floating-point types

[edit]

<climits>

Limits of integral types

[edit]

<compare>

(C++20)

Three-way comparison operator

support

[edit]

<contracts>

(C++26)

Contracts support library

[edit]

<coroutine>

(C++20)

Coroutine support library

[edit]

<csetjmp>

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

[edit]

<csignal>

Functions and macro constants for signal management

[edit]

<cstdarg>

Handling of variable length argument lists

[edit]

<cstddef>

Standard macros and typedefs

[edit]

<cstdint>

(C++11)

Fixed-width integer types

and

limits of other types

[edit]

<exception>

Exception handling utilities

[edit]

<initializer_list>

(C++11)

std::initializer_list

class template

[edit]

<limits>

Query properties of arithmetic types

[edit]

<new>

Low-level memory management utilities

[edit]

<source_location>

(C++20)

Supplies means to obtain

source code location

[edit]

<stdfloat>

(C++23)

Fixed-width floating-point types

[edit]

<typeindex>

(C++11)

std::type_index

[edit]

<typeinfo>

Runtime type information utilities

[edit]

<version>

(C++20)

Supplies macros for verifying implementation status of library

[edit]

Concepts library

<concepts>

(C++20)

Fundamental library concepts

[edit]

Diagnostics library

<cassert>

Conditionally compiled macro that compares its argument to zero

[edit]

<cerrno>

Macro containing the last error number

[edit]

<debugging>

(C++26)

Debugging library

[edit]

<stacktrace>

(C++23)

Stacktrace

library

[edit]

<stdexcept>

Standard exception types

[edit]

<system_error>

(C++11)

Defines

std::error_code

, a platform-dependent error code

[edit]

Memory management library

<memory>

High-level memory management utilities

[edit]

<memory_resource>

(C++17)

Polymorphic allocators and memory resources

[edit]

<scoped_allocator>

(C++11)

Nested allocator class

[edit]

Metaprogramming library

<meta>

(C++26)

Compile-time reflection support library

[edit]

<ratio>

(C++11)

Compile-time rational arithmetic

[edit]

<type_traits>

(C++11)

Compile-time type information utilities

[edit]

General utilities library

<any>

(C++17)

std::any

class

[edit]

<bit>

(C++20)

Bit manipulation

functions

[edit]

<bitset>

std::bitset

class template

[edit]

<expected>

(C++23)

std::expected class template

[edit]

<functional>

Function objects, Function invocations, Bind operations and Reference wrappers

[edit]

<optional>

(C++17)

std::optional

class template

[edit]

<tuple>

(C++11)

std::tuple

class template

[edit]

<utility>

Various

utility components

[edit]

<variant>

(C++17)

std::variant

class template

[edit]

Containers library

<array>

(C++11)

std::array

container

[edit]

<deque>

std::deque

container

[edit]

<flat_map>

(C++23)

std::flat_map and std::flat_multimap container adaptors

[edit]

<flat_set>

(C++23)

std::flat_set and std::flat_multiset container adaptors

[edit]

<forward_list>

(C++11)

std::forward_list

container

[edit]

<hive>

(C++26)

std::hive container

[edit]

<inplace_vector>

(C++26)

std::inplace_vector container

[edit]

<list>

std::list

container

[edit]

<map>

std::map

and

std::multimap

associative containers

[edit]

<mdspan>

(C++23)

std::mdspan view

[edit]

<queue>

std::queue

and

std::priority_queue

container adaptors

[edit]

<set>

std::set

and

std::multiset

associative containers

[edit]

<span>

(C++20)

std::span view

[edit]

<stack>

std::stack

container adaptor

[edit]

<unordered_map>

(C++11)

std::unordered_map

and

std::unordered_multimap

unordered associative containers

[edit]

<unordered_set>

(C++11)

std::unordered_set

and

std::unordered_multiset

unordered associative containers

[edit]

<vector>

std::vector

container

[edit]

Iterators library

<iterator>

Range iterators

[edit]

Ranges library

<generator>

(C++23)

std::generator class template

[edit]

<ranges>

(C++20)

Range access, primitives, requirements, utilities and adaptors

[edit]

Algorithms library

<algorithm>

Algorithms that operate on ranges

[edit]

<numeric>

Numeric operations on values in ranges

[edit]

Strings library

<cstring>

Various

narrow character string handling functions

[edit]

<string>

std::basic_string

class template

[edit]

<string_view>

(C++17)

std::basic_string_view

class template

[edit]

Text processing library

<cctype>

Functions to determine the category of narrow characters

[edit]

<charconv>

(C++17)

std::to_chars and std::from_chars

[edit]

<clocale>

C localization utilities

[edit]

<codecvt>

(C++11)(deprecated in C++17)(removed in C++26)

Unicode conversion facilities

[edit]

<cuchar>

(C++11)

C-style

Unicode character conversion functions

[edit]

<cwchar>

Various

wide

and

multibyte

string handling functions

[edit]

<cwctype>

Functions to determine the category of wide characters

[edit]

<format>

(C++20)

Formatting library

including

std::format

[edit]

<locale>

Localization utilities

[edit]

<regex>

(C++11)

Classes, algorithms and iterators to support regular expression processing

[edit]

<text_encoding>

(C++26)

Text encoding identifications

[edit]

Numerics library

<cfenv>

(C++11)

Floating-point environment

access functions

[edit]

<cmath>

Common mathematics functions

[edit]

<complex>

Complex number type

[edit]

<linalg>

(C++26)

Basic linear algebra algorithms (BLAS)

[edit]

<numbers>

(C++20)

Math constants

[edit]

<random>

(C++11)

Random number generators and distributions

[edit]

<simd>

(C++26)

Data-parallel types and operations on these types

[edit]

<valarray>

Class for representing and manipulating arrays of values

[edit]

Time library

<chrono>

(C++11)

C++ time utilities

[edit]

<ctime>

C-style time/date utilities

[edit]

Input/output library

<cinttypes>

(C++11)

Formatting macros

, intmax_t and uintmax_t math and conversions

[edit]

<cstdio>

C-style input-output functions

[edit]

<filesystem>

(C++17)

std::filesystem::path

class and

supporting functions

[edit]

<fstream>

std::basic_fstream

,

std::basic_ifstream

,

std::basic_ofstream

class templates and typedefs

[edit]

<iomanip>

Helper functions to control the format of input and output

[edit]

<ios>

std::ios_base

class,

std::basic_ios

class template and typedefs

[edit]

<iosfwd>

Forward declarations of all classes in the input/output library

[edit]

<iostream>

Several standard stream objects

[edit]

<istream>

std::basic_istream

class template and typedefs

[edit]

<ostream>

std::basic_ostream

,

std::basic_iostream

class templates and typedefs

[edit]

<print>

(C++23)

Formatted output library including std::print

[edit]

<spanstream>

(C++23)

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

[edit]

<sstream>

std::basic_stringstream

,

std::basic_istringstream

,

std::basic_ostringstream

class templates and typedefs

[edit]

<streambuf>

std::basic_streambuf

class template

[edit]

<strstream>

(deprecated in C++98)(removed in C++26)

std::strstream

,

std::istrstream

,

std::ostrstream

[edit]

<syncstream>

(C++20)

std::basic_osyncstream, std::basic_syncbuf and typedefs

[edit]

Concurrency support library

<atomic>

(C++11)

Atomic operations library

[edit]

<barrier>

(C++20)

Barriers

[edit]

<condition_variable>

(C++11)

Thread waiting conditions

[edit]

<future>

(C++11)

Primitives for asynchronous computations

[edit]

<hazard_pointer>

(C++26)

Hazard pointers

[edit]

<latch>

(C++20)

Latches

[edit]

<mutex>

(C++11)

Mutual exclusion primitives

[edit]

<rcu>

(C++26)

Read-copy update mechanisms

[edit]

<semaphore>

(C++20)

Semaphores

[edit]

<shared_mutex>

(C++14)

Shared mutual exclusion primitives

[edit]

<stop_token>

(C++20)

Stop tokens for

std::jthread

[edit]

<thread>

(C++11)

std::thread

class and

supporting functions

[edit]

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.

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.

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.

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>

[edit]

<ctype.h>

Behaves as if each name from

<cctype>

is placed in global namespace

[edit]

<errno.h>

Behaves same as

<cerrno>

[edit]

<fenv.h>

(C++11)

Behaves as if each name from

<cfenv>

is placed in global namespace

[edit]

<float.h>

Behaves same as

<cfloat>

[edit]

<inttypes.h>

(C++11)

Behaves as if each name from

<cinttypes>

is placed in global namespace

[edit]

<limits.h>

Behaves same as

<climits>

[edit]

<locale.h>

Behaves as if each name from

<clocale>

is placed in global namespace

[edit]

<math.h>

Behaves as if each name from

<cmath>

is placed in global namespace,
except for names of

mathematical special functions

[edit]

<setjmp.h>

Behaves as if each name from

<csetjmp>

is placed in global namespace

[edit]

<signal.h>

Behaves as if each name from

<csignal>

is placed in global namespace

[edit]

<stdarg.h>

Behaves as if each name from

<cstdarg>

is placed in global namespace

[edit]

<stddef.h>

Behaves as if each name from

<cstddef>

is placed in global namespace,
except for names of

std::byte and related functions

[edit]

<stdint.h>

(C++11)

Behaves as if each name from

<cstdint>

is placed in global namespace

[edit]

<stdio.h>

Behaves as if each name from

<cstdio>

is placed in global namespace

[edit]

<stdlib.h>

Behaves as if each name from

<cstdlib>

is placed in global namespace

[edit]

<string.h>

Behaves as if each name from

<cstring>

is placed in global namespace

[edit]

<time.h>

Behaves as if each name from

<ctime>

is placed in global namespace

[edit]

<uchar.h>

(C++11)

Behaves as if each name from

<cuchar>

is placed in global namespace

[edit]

<wchar.h>

Behaves as if each name from

<cwchar>

is placed in global namespace

[edit]

<wctype.h>

Behaves as if each name from

<cwctype>

is placed in global namespace

[edit]

The headers

<stdatomic.h>

,

<stdbit.h>

, and

<stdckdint.h>

declare names which are also provided in the C standard library. The header

<stdatomic.h>

also defines the

_Atomic

macro which is a

keyword

in C. Unlike other <xxx.h> headers, corresponding <cstdatomic>, <cstdbit>, and <cstdckdint> are not provided.

(C++23)

Defines _Atomic and provides corresponding components in the C standard library

[edit]

(C++26)

Provides corresponding components in the C standard library

[edit]

(C++26)

Provides corresponding components in the C standard library

[edit]

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.

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++

[edit]

<cstdalign>

(C++11)(deprecated in C++17)(removed in C++20)

Defines one

compatibility macro constant

[edit]

<cstdbool>

(C++11)(deprecated in C++17)(removed in C++20)

Defines one

compatibility macro constant

[edit]

<iso646.h>

Has no effect

[edit]

<stdalign.h>

(C++11)

Defines one

compatibility macro constant

[edit]

<stdbool.h>

(C++11)

Defines one

compatibility macro constant

[edit]

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

also define several collections of headers.

See also