Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C++ Standard Library
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Collection of classes and functions used in the C++ programming language}} {{Use dmy dates|date=December 2021}} {{C++ Standard library}} <!-- to edit this template go to [[template:C++_Standard_library]] --> In the [[C++]] programming language, the '''C++ Standard Library''' is a collection of [[class (computer science)|classes]] and [[subroutine|functions]], which are written in the [[core language]] and part of the C++ [[International Organization for Standardization|ISO]] Standard itself.<ref>ISO/IEC 14882:2003(E) ''Programming Languages – C++'' §17-27</ref> ==Overview== The C++ Standard Library provides several generic containers, functions to use and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O), support for some language features, and functions for common tasks such as finding the [[square root]] of a number. The C++ Standard Library also incorporates most headers of the ISO [[C standard library]] ending with "{{mono|.h}}", but their use was deprecated (reverted the deprecation since [[C++23]]<ref>{{Cite web|url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2340r1.html|title=Clarifying the status of the "C headers"|date=2021-06-11|first=Thomas|last=Köppe}}</ref>).<ref>ISO/IEC 14882:2003(E) ''Programming Languages – C++'' §D.5</ref> C++23 instead considers these headers as useful for interoperability with [[C (programming language)|C]], and recommends against their usage outside of programs that are intended to be both valid C and C++ programs. No other headers in the C++ Standard Library end in "{{mono|.h}}". Features of the C++ Standard Library are declared within the <code>std</code> [[namespace]]. The C++ Standard Library is based upon conventions introduced by the [[Standard Template Library]] (STL), and has been influenced by research in [[generic programming]] and developers of the STL such as [[Alexander Stepanov]] and Meng Lee.<ref>{{cite book | title=The Design and Evolution of C++ §8.5 | first=Bjarne | last=Stroustrup | year=1994 | publisher=Addison Wesley | isbn=0-201-54330-3 }}</ref><ref>{{cite web|url=http://www.hpl.hp.com/techreports/95/HPL-95-11.html|title=The Standard Template Library|first1=Alexander |last1=Stepanov |first2=Meng |last2=Lee|date=1 August 1994|publisher=HP Labs|access-date=22 October 2017}}</ref> Although the C++ Standard Library and the STL share many features, neither is a strict superset of the other.{{citation needed | date=November 2020}} The design of the C++ standard library, much like the C standard library, is minimalistic, and contains only core features for programming, lacking most of the more specialised features offered by the [[Java Class Library|Java standard library]] or [[Standard Libraries (CLI)|C# standard library]]. A noteworthy feature of the C++ Standard Library is that it not only specifies the syntax and semantics of generic algorithms, but also places requirements on their performance.<ref>"[http://www.cs.rpi.edu/~musser/gp/algorithms.html Generic Algorithms]", [[David Musser]]</ref> These performance requirements often correspond to a well-known algorithm, which is expected but not required to be used. In most cases this requires linear time O(''n'') or [[linearithmic time]] O(''n'' log ''n''), but in some cases higher bounds are allowed, such as [[quasilinear time]] O(''n'' log<sup>2</sup> ''n'') for stable sort (to allow [[In-place algorithm|in-place]] [[In-place merge sort|merge sort]]). Previously, sorting was only required to take O(''n'' log ''n'') on average, allowing the use of [[quicksort]], which is fast in practice but has poor worst-case performance, but [[introsort]] was introduced to allow both fast average performance and optimal worst-case complexity, and as of [[C++11]], sorting is guaranteed to be at worst linearithmic. In other cases requirements remain laxer, such as [[selection algorithm|selection]], which is only required to be linear on average (as in [[quickselect]]),<ref>{{cite web | url=http://en.cppreference.com/w/cpp/algorithm/nth_element | title=std::nth_element | publisher=cppreference.com | access-date=20 March 2018 }}</ref> not requiring worst-case linear as in [[introselect]]. The C++ Standard Library underwent ISO standardization as part of the C++ ISO Standardization effort in the 1990s. Since 2011, it has been expanded and updated every three years<ref>"[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1000r5.pdf C++ IS Schedule]", [[Herb Sutter]]</ref> with each revision of the C++ standard. Since C++23, the C++ Standard Library can be imported using [[Precompiled header#Modules|modules]], which were introduced in [[C++20]]. ==Implementations== {| class="wikitable sortable" ! Name || Organization || Homepage || Acronym || Licence || Latest release |- | GNU C++ Standard Library || [[GNU Project]] and [[Free Software Foundation]] || [https://gcc.gnu.org/] || libstdc++ || [[GPLv3]] with [[GCC Runtime Library Exception]] || New major release once per year |- | LLVM C++ Standard Library || [[LLVM Developer Group]] || [https://libcxx.llvm.org/] || libc++ || [[Apache License 2.0 with LLVM Exceptions]] || Every 2 weeks |- | NVIDIA C++ Standard Library || [[Nvidia]] || [https://github.com/NVIDIA/cccl/tree/main/libcudacxx] || libcudacxx || [[Apache License 2.0 with LLVM Exceptions]] || {{Start date and age|2024|9|4}} |- | Microsoft C++ Standard Library || [[Microsoft]] || [https://github.com/microsoft/STL] || MSVC STL || [[Apache License 2.0 with LLVM Exceptions]] || Daily |- | HPX C++ Standard Library for Parallelism and Concurrency || [[STELLAR Group]] || [https://github.com/STEllAR-GROUP/hpx] || HPX || [[Boost (C++ libraries)#License|Boost Software License 1.0]] || {{Start date and age|2024|5|29}} |- | Electronic Arts Standard Template Library || [[Electronic Arts]] || [https://github.com/electronicarts/EASTL] || EASTL || [[BSD 3-Clause License]] || {{Start date and age|2024|8|31}} |- | Dinkum C++ Library || [[Dinkumware]] || [http://www.dinkumware.com/] || Unknown || Commercial || Unknown |- | Cray C++ Standard Library || [[Cray User Group]] || [https://cug.org/] || Unknown || Commercial || Unknown |} ===Discontinued=== ====Apache C++ Standard Library==== The [[Apache C++ Standard Library]] is another open-source implementation. It was originally developed commercially by [[Rogue Wave Software]] and later donated to the [[Apache Software Foundation]].<ref>[http://stdcxx.apache.org/ Apache C++ Standard Library]</ref> However, after more than five years without a release, the board of the Apache Software Foundation decided to end this project and move it to Apache Attic.<ref>{{cite web |url=http://mail-archives.apache.org/mod_mbox/stdcxx-dev/201307.mbox/%3C0F1B5FEB-9312-44CA-96CF-B586B8CE6BA4@apache.org%3E |title=Apache C++ Standard Library and the Attic |first=Brett |last=Porter |date=18 July 2013 |publisher=stdcxx-dev mailing list |access-date=27 February 2014}}</ref> ===See also=== The following libraries implement much of the C++ Standard Library: {| class="wikitable" ! Name !! Homepage !! Description |- | Abseil || [https://github.com/abseil/abseil-cpp]|| An open source collection of libraries used internally by Google |- | Folly || [https://github.com/facebook/folly]|| A variety of [[C++14]] libraries that are used extensively by Facebook |- | Bareflank Support Library || [https://github.com/Bareflank/bsl]|| A C++ library where everything can be executed at compile time |} ==Standard modules== Although [[Precompiled header#Modules|modules]] were first introduced in [[C++20]], standard library modules were only standardised as part of the language in [[C++23]]. These named modules were added to include all items declared in both global and <code>std</code> namespaces provided by the importable standard headers. Macros are not allowed to be exportable, so users have to manually include or import headers that emit macros for use. The C++ standard has reserved <code>std</code> and <code>std.*</code> as module names,<ref name="P2465R3">C++ Standards Committee. (2022). ''P2465R3 - C++ Modules: Design and Evolution''. Retrieved from [https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2465r3.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2465r3.pdf]</ref> however most compilers allow a flag to override this.<ref>{{Cite web|title=Standard C++ modules|url=https://clang.llvm.org/docs/StandardCPlusPlusModules.html}}</ref> The current standard library modules defined by the standard as of C++23 are: {| class="wikitable" ! Name !! Description |- | {{code|std}} || Exports all declarations in namespace <code>std</code> and global storage allocation and deallocation functions that are provided by the importable C++ library headers including C library facilities (although declared in standard namespace). |- | {{code|std.compat}} || Exports the same declarations as the named module <code>std</code>, and additionally exports functions in global namespace in C library facilities. It thus contains "compat" in the name, meaning compatibility with C. |} The above modules export the entire C++ standard library, meaning that as of currently, the standard library must be imported in its entirety. Furthermore, modules do not allow for granular imports of specific namespaces, classes, or symbols within a module, unlike [[Java (programming language)|Java]] or [[Rust (programming language)|Rust]] which do allow for the aforementioned. Importing a module imports all symbols marked with <code>export</code>, making it akin to a wildcard import in Java or Rust. Like [[Java package|Java's packages]], C++ modules do not have a hierarchical system, but typically use a hierarchical naming convention. In other words, C++ does not have "submodules", meaning the <code>.</code> symbol which may be included in a module name bears no syntactic meaning and is used only to suggest the association of a module. As an example, <code>std.compat</code> is not a submodule of <code>std</code>, but is named so to indicate the association the module bears to the <code>std</code> module (as a "compatibility" version of it). It has been proposed that additional modules providing other subsets of the standard library be added, which may eventually be included in a future revision.<ref name="P0581R1">C++ Standards Committee. (2018). ''P0581R1 - Modules for C++''. Retrieved from [https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0581r1.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0581r1.pdf]</ref><ref name="P2412R0">C++ Standards Committee. (2021). ''P2412R0 - Further refinements to the C++ Modules Design''. Retrieved from [https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2412r0.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2412r0.pdf]</ref> These include: {| class="wikitable" ! Name !! Description |- | {{code|std.fundamental}} || Exports the utility facilities within the C++ standard library. |- | {{code|std.core}} || Exports everything in {{code|std.fundamental}}, as well as [[Container (abstract data type)|container]] facilities and the [[Standard Template Library]] (STL), and other data types such as [[C++ string handling|strings]], [[regular expression]]s, and [[smart pointer]]s. |- | {{code|std.io}} || Exports facilities for [[Input/output (C++)|input/output]]. |- | {{code|std.os}} || Exports facilities for interfacing with the operating system as well as filesystem manipulation. |- | {{code|std.concurrency}} || Exports facilities for concurrent programming. |- | {{code|std.math}} || Exports facilities for mathematics and pseudorandom number generation. |} ==Standard headers== The following files contain the declarations of the C++ Standard Library. Legend:<br> {{color box|#E6E6B7}}: Deprecated<br> {{color box|#F99}}: Removed ===General=== Components that C++ programs may use for increased features. {| class="wikitable" ! Name !! Description |- | {{code|<any>}} || Added in [[C++17]]. Provides a type-erased class <code>std::any</code>. |- | {{code|<atomic>}} || Added in [[C++11]]. Provides class template <code>std::atomic</code>, its several template specializations, and more atomic operations. |- | {{code|<chrono>}} || Provides time elements, such as <code>std::chrono::duration</code>, <code>std::chrono::time_point</code>, and clocks. Since [[C++20]], a hefty amount of temporal features were added: calendars, time zones, more clocks, and string chrono formatting. |- | {{code|<concepts>}} || Added in [[C++20]]. Provides fundamental library [[Concepts (C++)|concepts]]. |- | {{code|<expected>}} || Added in [[C++23]]. Provides class template <code>std::expected</code>, a [[result type]]. |- | {{code|<functional>}} || Provides several [[function object]]s, designed for use with the standard algorithms. |- | {{code|<generator>}} || Added in [[C++23]]. Provides a [[Generator (computer programming)|coroutine generator]] that additionally supports nested yield operations on ranges. |- | {{code|<memory>}} || Provides facilities for [[memory management]] in C++, including the class template <code>std::unique_ptr</code>. |- | {{code|<memory_resource>}} || Added in [[C++17]]. Provides facilities for creating polymorphic memory allocators whose behaviors can change at runtime.<ref>{{Cite web|last=Filipek|first=Bartlomiej|title=Polymorphic Allocators, std::vector Growth and Hacking|url=https://www.bfilipek.com/2020/06/pmr-hacking.html|access-date=2021-04-30|language=en}}</ref> |- | {{code|<optional>}} || Added in [[C++17]]. Provides class template <code>std::optional</code>, an [[Option type|optional type]]. |- | {{code|<scoped_allocator>}} || Added in [[C++11]]. Provides <code>std::scoped_allocator_adaptor</code>. |- | {{code|<stacktrace>}} || Added in [[C++23]]. Provides [[stack trace]] operations. |- | {{code|<stdexcept>}} || Contains standard exception classes such as <code>std::logic_error</code> and <code>std::runtime_error</code>, both derived from <code>std::exception</code>. |- | {{code|<system_error>}} || Added in [[C++11]]. Defines <code>std::error_code</code> |- | {{code|<tuple>}} || Added in [[C++11]] and TR1. Provides a class template <code>std::tuple</code>, a [[tuple]]. |- | {{code|<type_traits>}} || Added in [[C++11]]. Provides metaprogramming facilities working with types. |- | {{code|<utility>}} || The [[Utility (C++)|utility file]] provides various utilities: class template <code>std::pair</code> (two-member [[tuple]]s), compile-time integer sequences, helpers in constructing vocabulary types, functions such as <code>std::move</code> and <code>std::forward</code>, and many more. The namespace <code>std::rel_ops</code> for automatically generating comparison operators is deprecated in [[C++20]] in favor of new defaulted comparison operators. |- | {{code|<variant>}} || Added in [[C++17]]. Provides a class template <code>std::variant</code>, a [[Tagged union|tagged union type]]. |} ===Language support=== Components that C++ programs may use for support during development. {| class="wikitable" ! Name !! Description |- | {{code|<compare>}} || Added in [[C++20]]. Provides [[Three-way comparison|three-way comparison operator]] support. |- | {{code|<coroutine>}} || Added in [[C++20]]. Provides [[coroutine]] support. |- | {{code|<debugging>}} || Added in [[C++26]]. Provides [[debugging]] support. |- | {{code|<exception>}} || Provides several types and functions related to [[exception handling]], including <code>std::exception</code>, the base class of all exceptions thrown by the Standard Library. |- | {{code|<initializer_list>}} || Added in [[C++11]]. Provides initializer list support. |- | {{code|<limits>}} || Provides the class template <code>std::numeric_limits</code>, used for describing properties of fundamental numeric types. |- | {{code|<new>}} || Provides operators <code>new</code> and <code>delete</code> and other functions and types composing the fundamentals of C++ [[memory management]]. |- | {{code|<source_location>}} || Added in [[C++20]]. Provides capturing source location information as alternative to predefined macros such as <code>__LINE__</code>. |- | {{code|<stdfloat>}} || Added in [[C++23]]. Provides conditional support for extended floating-point types. |- | {{code|<typeinfo>}} || Provides facilities for working with C++ [[run-time type information]]. |- | {{code|<version>}} || Added in [[C++20]]. Provides information about the implementation of the C++ standard library.<ref>{{Cite web|date=2020-04-01|title=Working Draft, Standard for Programming Language C++|url=http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/n4861.pdf|url-status=live|access-date=2021-04-30|website=open-std.org|publisher=ISO/IEC|page=492|archive-url=https://web.archive.org/web/20200427145844/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4861.pdf |archive-date=27 April 2020 }}</ref> |} ===Containers=== {{See also|Standard Template Library}} Components that C++ programs may use for [[Container (abstract data type)|container data structures]]. {| class="wikitable" ! Name !! Description |- | {{code|<array>}} || Added in [[C++11]] and [[C++ Technical Report 1|TR1]]. Provides the container class template <code>[[array (C++)|std::array]]</code>, a container for a fixed sized array. |- | {{code|<bitset>}} || Provides the specialized container class <code>std::bitset</code>, a [[bit array]]. |- | {{code|<deque>}} || Provides the container class template <code>[[deque (C++)|std::deque]]</code>, a [[deque|double-ended queue]]. |- | {{code|<flat_map>}} || Added in [[C++23]]. Provides the container adapter class templates <code>std::flat_map</code> and <code>std::flat_multimap</code>. |- | {{code|<flat_set>}} || Added in [[C++23]]. Provides the container adapter class templates <code>std::flat_set</code> and <code>std::flat_multiset</code>. |- | {{code|<forward_list>}} || Added in [[C++11]] and [[C++ Technical Report 1|TR1]]. Provides the container class template <code>[[forward list (C++)|std::forward_list]]</code>, a [[Linked list|singly linked list]]. |- | {{code|<inplace_vector>}} || Added in [[C++26]]. Provides the class <code>std::inplace_vector</code>, analogous to <code>std::vector</code> with a fixed capacity defined at compile time. |- | {{code|<map>}} || Provides the container class templates <code>[[map (C++)|std::map]]</code> and <code>std::multimap</code>, sorted [[associative array]] and [[Multimap (data structure)|multimap]]. |- | {{code|<mdspan>}} || Added in [[C++23]]. Provides the class template <code>std::mdspan</code>, analogous to <code>std::span</code> but the view is multidimensional. |- | {{code|<queue>}} || Provides the container adapter class <code>std::queue</code>, a single-ended [[Queue (data structure)|queue]], and <code>std::priority_queue</code>, a [[priority queue]]. |- | {{code|<set>}} || Provides the container class templates <code>[[set (C++)|std::set]]</code> and <code>std::multiset</code>, sorted associative containers or [[Set (computer science)|set]]s. |- | {{code|<span>}} || Added in [[C++20]]. Provides the class template <code>std::span</code>, a non-owning view that refers to any contiguous range. |- | {{code|<stack>}} || Provides the container adapter class <code>[[stack (C++)|std::stack]]</code>, a [[Stack (data structure)|stack]]. |- | {{code|<unordered_map>}} || Added in [[C++11]] and [[C++ Technical Report 1|TR1]]. Provides the container class template <code>[[unordered map (C++)|std::unordered_map]]</code> and <code>std::unordered_multimap</code>, [[hash table]]s. |- | {{code|<unordered_set>}} || Added in [[C++11]] and [[C++ Technical Report 1|TR1]]. Provides the container class template <code>[[unordered set (C++)|std::unordered_set]]</code> and <code>std::unordered_multiset</code>. |- | {{code|<vector>}} || Provides the container class template <code>[[vector (C++)|std::vector]]</code>, a [[dynamic array]]. |} ===Iterators and ranges=== Components that C++ programs may use to manipulate iterators, ranges, and algorithms over ranges and containers. {| class="wikitable" ! Name !! Description |- | {{code|<algorithm>}} || Provides definitions of many [[algorithm]]s for use with containers and other ranges. |- | {{code|<execution>}} || Added in [[C++17]]. Provides execution policies for parallelized algorithms. |- | {{code|<iterator>}} || Provides classes and templates for working with [[iterator]]s. |- | {{code|<numeric>}} || Generalized numeric algorithms. |- | {{code|<ranges>}} || Added in [[C++20]]. Provides [[Range (computer programming)|ranges]] facilities and lazily evaluated adapters. |} ===Localisation=== Components that C++ programs may use for localisation and character encoding manipulation. {| class="wikitable" ! Name !! Description |- | style="background:#F99" | {{code|<codecvt>}} | style="background:#F99" | Provides code conversion facets for various character encodings. Deprecated since [[C++17]], removed in [[C++26]]. |- | {{code|<locale>}} || Defines classes and declares functions that encapsulate and manipulate the information peculiar to a [[Locale (computer software)|locale]]. |- | {{code|<text_encoding>}} || Added in [[C++26]]. Provides text encoding identifications. |} ===Strings=== Components that C++ programs may use for string manipulation. {| class="wikitable" ! Name !! Description |- | {{code|<charconv>}} || Added in [[C++17]]. Provides a locale-independent, non-allocating, and non-throwing string conversion utilities from/to integers and floating point. |- | {{code|<format>}} || Added in [[C++20]]. Provides a modern way of formatting strings including <code>std::format</code>. |- | {{code|<string>}} || Provides the C++ standard [[String (C++)|string]] classes and templates. |- | {{code|<string_view>}} || Added in [[C++17]]. Provides class template <code>std::basic_string_view</code>, an immutable non-owning view to any string. |- | {{code|<regex>}} || Added in [[C++11]]. Provides utilities for pattern matching strings using [[regular expressions]]. |} ===Streams, files, and input/output=== Components that C++ programs may use for input/output manipulation and file manipulation. {| class="wikitable" ! Name !! Description |- | {{code|<filesystem>}} || Added in [[C++17]]. Provides facilities for [[file system]] operations and their components. |- | {{code|<fstream>}} || Provides facilities for file-based input and output. See [[fstream]]. |- | {{code|<iomanip>}} || Provides facilities to manipulate output formatting, such as the [[Radix|base]] used when formatting integers and the [[arithmetic precision|precision]] of [[floating-point arithmetic|floating-point]] values. |- | {{code|<ios>}} || Provides several types and functions basic to the operation of iostreams. |- | {{code|<iosfwd>}} || Provides [[forward declaration]]s of several I/O-related class templates. |- | {{code|<iostream>}} || Provides C++ input and output fundamentals. See [[iostream]]. |- | {{code|<istream>}} || Provides <code>std::istream</code> and other supporting classes for input. |- | {{code|<ostream>}} || Provides <code>std::ostream</code> and other supporting classes for output. |- | {{code|<print>}} || Added in [[C++23]]. Provides formatted output utilities such as <code>std::print</code> supported for both C and C++ streams. |- | {{code|<spanstream>}} || Added in [[C++23]]. Provides <code>std::spanstream</code> and other fixed character buffer I/O streams. |- | {{code|<sstream>}} || Provides <code>std::stringstream</code> and other supporting classes for string manipulation. |- | {{code|<streambuf>}} || Provides reading and writing functionality to/from certain types of character sequences, such as external files or strings. |- | style="background:#F99" | {{code|<strstream>}} | style="background:#F99" | Provides input/output operations on array-backed streams. Deprecated in [[C++98]], removed in [[C++26]]. |- | {{code|<syncstream>}} || Added in [[C++20]]. Provides <code>std::osyncstream</code> and other supporting classes for synchronized output streams. |} ===Thread support library=== Components that C++ programs may use for threading and concurrent programming. {| class="wikitable" ! Name !! Description |- | {{code|<barrier>}} || Added in [[C++20]]. Provides <code>std::barrier</code>, a reusable thread barrier. |- | {{code|<future>}} || Added in [[C++11]]. In 32.9.1-1, this section describes components that a C++ program can use to retrieve in one thread the result (value or exception) from a function that has run in the same thread or another thread. |- | {{code|<hazard_pointer>}} || Added in [[C++26]]. Provides [[Hazard pointer|<code>std::hazard_pointer</code>]]. |- | {{code|<latch>}} || Added in [[C++20]]. Provides <code>std::latch</code>, a single-use thread barrier. |- | {{code|<mutex>}} || Added in [[C++11]]. In 32.5-1, this section provides mechanisms for mutual exclusion: mutexes, locks, and call once. |- | {{code|<rcu>}} || Added in [[C++26]]. Provides [[Read-copy-update|read-copy-update mechanisms]]. |- | {{code|<shared_mutex>}} || Added in [[C++14]]. Provides facility for shared mutual exclusion. |- | {{code|<semaphore>}} || Added in [[C++20]]. Provides [[Semaphore (programming)|semaphore]] that models non-negative resource count. |- | {{code|<stop_token>}} || Added in [[C++20]]. In 32.3.1-1, this section describes components that can be used to asynchronously request that an operation stops execution in a timely manner, typically because the result is no longer required. Such a request is called a stop request. |- | {{code|<thread>}} || Added in [[C++11]]. Provide class and namespace for working with threads. |} ===Numerics library=== Components that C++ programs may use to perform seminumerical or mathematical operations. {| class="wikitable" ! Name !! Description |- | {{code|<bit>}} || Added in [[C++20]]. Provides bit manipulation facilities. |- | {{code|<complex>}} || Defines a class template <code>std::complex</code>, and numerous functions for representing and manipulating complex numbers. |- | {{code|<linalg>}} || Added in [[C++26]]. Provides [[linear algebra]] facilities. |- | {{code|<numbers>}} || Added in [[C++20]]. Provides mathematical constants defined in namespace <code>std::numbers</code>. |- | {{code|<simd>}} || Added in [[C++26]]. Provides data-parallel types and operations on these types. |- | {{code|<random>}} || Added in [[C++11]]. Facility for generating (pseudo-)random numbers and distributions. |- | {{code|<ratio>}} || Added in [[C++11]]. Provides compile-time rational arithmetic based on class templates. |- | {{code|<valarray>}} || Defines five class templates (<code>std::valarray</code>, <code>std::slice_array</code>, <code>std::gslice_array</code>, <code>std::mask_array</code>, and <code>std::indirect_array</code>), two classes (<code>std::slice</code> and <code>std::gslice</code>), and a series of related function templates for representing and manipulating arrays of values. |} ===C standard library=== {{Main article|C standard library}} Each header from the C Standard Library is included in the C++ Standard Library under a different name, generated by removing the '{{mono|.h}}' file extension, and adding a '{{mono|c}}' at the start; for example, '<code>time.h</code>' becomes '<code>ctime</code>'. The only difference between these headers and the traditional C Standard Library headers is that where possible the functions should be placed into the <code>std::</code> namespace. In ISO C, functions in the standard library are allowed to be implemented by [[C preprocessor|macros]], which is not allowed by ISO C++. Usage of the C headers with the '{{mono|.h}}' file extension is legal in C++ and used for compatibility. {| class="wikitable" ! Name !! Description |- | {{code|<cassert>}} || Related to <code>[[assert.h|<assert.h>]]</code>. Declares the [[assertion (computing)|assert]] macro, used to assist with detecting logical errors and other types of bugs while [[debugging]] a program. |- | style="background:#F99" | {{code|<ccomplex>}} | style="background:#F99" | Related to <code>[[complex.h|<complex.h>]]</code>. Defines a [[C mathematical functions#complex.h|set of functions]] for manipulating [[complex number]]s. Deprecated in [[C++17]], removed in [[C++20]]. |- | {{code|<cctype>}} || Related to <code>[[ctype.h|<ctype.h>]]</code>. Defines [[C character classification|set of functions]] used to classify characters by their types or to convert between upper and lower case in a way that is independent of the used [[character set]] (typically [[ASCII]] or one of its extensions, although implementations utilizing [[EBCDIC]] are also known). |- | {{code|<cerrno>}} || Related to <code>[[errno.h|<errno.h>]]</code>. For testing error codes reported by library functions. |- | {{code|<cfenv>}} || Related to <code>[[errno.h|<errno.h>]]</code>. Defines a [[C mathematical functions#fenv.h|set of functions]] for controlling [[floating-point]] environment. |- | {{code|<cfloat>}} || Related to <code>[[float.h|<float.h>]]</code>. Defines [[C data types#float.h|macro constants]] specifying the implementation-specific properties of the [[floating-point]] library. |- | {{code|<cinttypes>}} || Related to <code>[[inttypes.h|<inttypes.h>]]</code>. Defines [[C data types#inttypes.h|exact-width integer types]]. |- | style="background:#F99" | {{code|<ciso646>}} | style="background:#F99" | Related to <code>[[iso646.h|<iso646.h>]]</code>. Defines [[C alternative tokens|several macros]] that implement alternative ways to express several standard tokens. For programming in [[ISO 646]] variant character sets. Removed in [[C++20]]. |- | {{code|<climits>}} || Related to <code>[[limits.h|<limits.h>]]</code>. Defines [[C data types#limits.h|macro constants]] specifying the implementation-specific properties of the integer types. |- | {{code|<clocale>}} || Related to <code><locale.h></code>. Defines [[C localization functions|localization functions]]. |- | {{code|<cmath>}} || Related to <code>[[math.h|<math.h>]]</code>. Defines [[C mathematical functions|common mathematical functions]]. Extends <code><math.h></code>, containing special mathematical functions such as [[Bessel function]]s and the [[Riemann zeta function]]. |- | {{code|<csetjmp>}} || Related to <code>[[setjmp.h|<setjmp.h>]]</code>. Declares the macros <code>setjmp</code> and <code>longjmp</code>, which are used for non-local exits. |- | {{code|<csignal>}} || Related to <code>[[signal.h|<signal.h>]]</code>. Defines [[C signal handling|signal-handling functions]]. |- | style="background:#F99" | {{code|<cstdalign>}} | style="background:#F99" | Related to <code><stdalign.h></code>. For querying and specifying the [[Data structure alignment|alignment]] of objects. Deprecated in [[C++17]], removed in [[C++20]]. |- | {{code|<cstdarg>}} || Related to <code>[[stdarg.h|<stdarg.h>]]</code>. For [[Linearizability|atomic operations]] on data shared between threads. |- | style="background:#F99" | {{code|<cstdbool>}} | style="background:#F99" | Related to <code>[[stdbool.h|<stdbool.h>]]</code>. Defines [[C data types#stdbool.h|a Boolean data type]]. Deprecated in [[C++17]], removed in [[C++20]]. |- | {{code|<cstddef>}} || Related to <code>[[stddef.h|<stddef.h>]]</code>. Defines [[C data types#stddef.h|several useful types and macros]]. |- | {{code|<cstdint>}} || Related to <code>[[stdint.h|<stdint.h>]]</code>. Defines [[C data types#stdint.h|exact-width integer types]]. |- | {{code|<cstdio>}} || Related to <code>[[stdio.h|<stdio.h>]]</code>. Defines [[C file input/output|core input and output functions]]. |- | {{code|<cstring>}} || Related to <code>[[string.h|<string.h>]]</code>. Defines [[C string handling|string-handling functions]]. |- | style="background:#F99" | {{code|<ctgmath>}} | style="background:#F99" | Related to <code>[[tgmath.h|<tgmath.h>]]</code>. Defines [[C mathematical functions#tgmath.h|type-generic mathematical functions]]. Deprecated in [[C++17]], removed in [[C++20]]. |- | {{code|<ctime>}} || Related to <code>[[time.h|<time.h>]]</code>. Defines [[C date and time functions|date- and time-handling functions]]. |- | {{code|<cuchar>}} || Related to <code><uchar.h></code>. Types and functions for manipulating [[Unicode]] characters. |- | {{code|<cwchar>}} || Related to <code>[[wchar.h|<wchar.h>]]</code>. Defines [[C string handling|wide-string-handling functions]]. |- | {{code|<cwctype>}} || Related to <code>[[wctype.h|<wctype.h>]]</code>. Defines [[C character classification|set of functions]] used to classify wide characters by their types or to convert between upper and lower case. |} The following headers are special C compatibility headers which do not have a corresponding C++ naming convention, meaning that the C headers ''must'' be used if the header is necessary. {| class="wikitable" ! Name !! Description |- | {{code|<stdatomic.h>}} || Added in [[C++23]]. Related to <code><stdatomic.h></code>. For [[Linearizability|atomic operations]] on data shared between threads. |} The C headers <code><stdnoreturn.h></code> and <code><threads.h></code> do not have C++ equivalents and their C headers are not supported in C++. C++ does not provide the [[C POSIX library]] as part of any standard, however it is legal to use in a C++ program. If used in C++, the POSIX headers are not prepended with a "{{mono|c}}" at the beginning of the name, and all contain the {{mono|.h}} suffix in the header name. Most headers in the POSIX library typically have a C++ equivalent implementation, such as <code><regex></code> rather than <code><regex.h></code>. ==See also== * [[C standard library]] * [[C POSIX library]] * [[Standard library]] * [[Boost (C++ libraries)]] * [[C++ Technical Report 1]] ==References== {{Reflist}} ==Further reading== * {{cite book |title=The C++ Programming Language |last=Stroustrup |first=Bjarne |year=2013 |publisher=[[Addison-Wesley]] |isbn=978-0321563842}} * {{cite book |title=The C++ Standard Library – A Tutorial and Reference |last=Josuttis |first=Nicolai |year=2012 |publisher=[[Addison-Wesley]] |isbn=978-0-321-62321-8 |url=http://www.cppstdlib.com/}} * {{cite book |title=C++ Standard Library Quick Reference |last1=Van Weert |first1=Peter |last2=Gregoire |first2=Marc |date=14 June 2016 |publisher=[[Apress]] |isbn=978-1484218754 |url=http://cppcoders.com/quickref/ |access-date=24 March 2017 |archive-date=16 May 2021 |archive-url=https://web.archive.org/web/20210516181139/http://cppcoders.com/quickref/ |url-status=dead }} ==External links== * [http://en.cppreference.com/w/cpp C++ Standard Library reference] * [https://docs.microsoft.com/en-us/cpp/standard-library/cpp-standard-library-reference Microsoft C++ Standard Library Reference] * [https://www.roguewave.com/help-support/documentation/sourcepro Rogue Wave SourcePro C++ documentation] * [https://wiki.apache.org/stdcxx Apache C++ Standard Library Wiki], [https://stdcxx.apache.org retired 15 May 2014] (based on Rogue Wave C++ Standard Library 4.1.0) * [http://www.stlport.org/doc/ STLport C++ Standard Library documentation] * [https://gcc.gnu.org/onlinedocs/libstdc++/ The GNU C++ Library online documentation] * [https://libcxx.llvm.org/docs/ LLVM/Clang C++ Standard Library documentation] {{C++ programming language}} {{Apache Software Foundation}} [[Category:C++ Standard Library| ]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Apache Software Foundation
(
edit
)
Template:C++ Standard library
(
edit
)
Template:C++ programming language
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Color box
(
edit
)
Template:Main article
(
edit
)
Template:Mono
(
edit
)
Template:Reflist
(
edit
)
Template:See also
(
edit
)
Template:Short description
(
edit
)
Template:Start date and age
(
edit
)
Template:Use dmy dates
(
edit
)