Loading AI tools
Collection of classes and functions used in the C++ programming language From Wikipedia, the free encyclopedia
In the C++ programming language, the C++ Standard Library is a collection of classes and functions, which are written in the core language and part of the C++ ISO Standard itself.[1]
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 ".h", but their use was deprecated (reverted the deprecation since C++23[2]).[3] C++23 instead considers these headers as useful for interoperability with 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 ".h". Features of the C++ Standard Library are declared within the std
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.[4][5] Although the C++ Standard Library and the STL share many features, neither is a strict superset of the other.[citation needed]
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.[6] 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 log2 n) for stable sort (to allow in-place 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, which is only required to be linear on average (as in quickselect),[7] 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[8] with each revision of the C++ standard.
Name | Organization | Homepage | Acronym | Licence | Latest release |
---|---|---|---|---|---|
GNU C++ Standard Library | GNU Project and Free Software Foundation | libstdc++ | GPLv3 with GCC Runtime Library Exception | New major release once per year | |
LLVM C++ Standard Library | LLVM Developer Group | libc++ | Apache License 2.0 with LLVM Exceptions | Every 2 weeks | |
NVIDIA C++ Standard Library | Nvidia | libcudacxx | Apache License 2.0 with LLVM Exceptions | September 4, 2024 | |
Microsoft C++ Standard Library | Microsoft | MSVC STL | Apache License 2.0 with LLVM Exceptions | Daily | |
HPX C++ Standard Library for Parallelism and Concurrency | STELLAR Group | HPX | Boost Software License 1.0 | May 29, 2024 | |
Electronic Arts Standard Template Library | Electronic Arts | EASTL | BSD 3-Clause License | August 31, 2024 | |
Dinkum C++ Library | Dinkumware | Unknown | Commercial | Unknown | |
Cray C++ Standard Library | Cray User Group | Unknown | Commercial | Unknown |
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.[9] 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.[10]
The following libraries implement much of the C++ Standard Library:
Name | Homepage | Description |
---|---|---|
Abseil | An open source collection of libraries used internally by Google | |
Folly | A variety of C++14 libraries that are used extensively by Facebook | |
Bareflank Support Library | A C++ library where everything can be executed at compile time |
Ever since the modules were introduced in C++20, there has been no support for standard library modules until C++23. These named modules were added to include all items declared in both global and std
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.
std
std
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).std.compat
std
, and additionally exports functions in global namespace in C library facilities.The following files contain the declarations of the C++ Standard Library.
<any>
std::any
.<atomic>
std::atomic
, its several template specializations, and more atomic operations.<chrono>
std::chrono::duration
, std::chrono::time_point
, and clocks. Since C++20, a hefty amount of temporal features were added: calendars, time zones, more clocks, and string chrono formatting.<concepts>
<expected>
std::expected
, a result type.<functional>
<generator>
<memory>
std::unique_ptr
.<memory_resource>
<optional>
std::optional
, an optional type.<scoped_allocator>
std::scoped_allocator_adaptor
.<stacktrace>
<stdexcept>
std::logic_error
and std::runtime_error
, both derived from std::exception
.<system_error>
std::error_code
<tuple>
std::tuple
, a tuple.<type_traits>
<utility>
std::pair
(two-member tuples), compile-time integer sequences, helpers in constructing vocabulary types, functions such as std::move
and std::forward
, and many more. The namespace std::rel_ops
for automatically generating comparison operators is deprecated in C++20 in favor of new defaulted comparison operators.<variant>
std::variant
, a tagged union type.<compare>
<coroutine>
<exception>
std::exception
, the base class of all exceptions thrown by the Standard Library.<initializer_list>
<limits>
std::numeric_limits
, used for describing properties of fundamental numeric types.<new>
new
and delete
and other functions and types composing the fundamentals of C++ memory management.<source_location>
__LINE__
.<stdfloat>
<typeinfo>
<version>
<array>
std::array
, a container for a fixed sized array.<bitset>
std::bitset
, a bit array.<deque>
std::deque
, a double-ended queue.<flat_map>
std::flat_map
and std::flat_multimap
.<flat_set>
std::flat_set
and std::flat_multiset
.<forward_list>
std::forward_list
, a singly linked list.<list>
std::list
, a doubly linked list.<map>
std::map
and std::multimap
, sorted associative array and multimap.<mdspan>
std::mdspan
, analogous to std::span
but the view is multidimensional.<queue>
std::queue
, a single-ended queue, and std::priority_queue
, a priority queue.<set>
std::set
and std::multiset
, sorted associative containers or sets.<span>
std::span
, a non-owning view that refers to any contiguous range.<stack>
std::stack
, a stack.<unordered_map>
std::unordered_map
and std::unordered_multimap
, hash tables.<unordered_set>
std::unordered_set
and std::unordered_multiset
.<vector>
std::vector
, a dynamic array.<algorithm>
<execution>
<iterator>
<numeric>
<ranges>
<charconv>
<format>
std::format
.<string>
<string_view>
std::basic_string_view
, an immutable non-owning view to any string.<regex>
<filesystem>
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
std::istream
and other supporting classes for input.<ostream>
std::ostream
and other supporting classes for output.<print>
std::print
supported for both C and C++ streams.<spanstream>
std::spanstream
and other fixed character buffer I/O streams.<sstream>
std::stringstream
and other supporting classes for string manipulation.<streambuf>
<syncstream>
std::osyncstream
and other supporting classes for synchronized output streams.<barrier>
std::barrier
, a reusable thread barrier.<condition_variable>
<future>
<hazard_pointer>
std::hazard_pointer
.<latch>
std::latch
, a single-use thread barrier.<mutex>
<rcu>
<shared_mutex>
<semaphore>
<stop_token>
<thread>
Components that C++ programs may use to perform seminumerical operations.
<bit>
<complex>
std::complex
, and numerous functions for representing and manipulating complex numbers.<numbers>
std::numbers
.<random>
<ratio>
<valarray>
std::valarray
, std::slice_array
, std::gslice_array
, std::mask_array
, and std::indirect_array
), two classes (std::slice
and std::gslice
), and a series of related function templates for representing and manipulating arrays of values.Each header from the C Standard Library is included in the C++ Standard Library under a different name, generated by removing the .h, and adding a 'c' at the start; for example, 'time.h' becomes 'ctime'. The only difference between these headers and the traditional C Standard Library headers is that where possible the functions should be placed into the std::
namespace. In ISO C, functions in the standard library are allowed to be implemented by macros, which is not allowed by ISO C++.
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.