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++
(section)
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!
==Standard library== [[File:ANSI ISO C++ WP.jpg|thumb|right|The draft "Working Paper" standard that became approved as C++98; half of its size was devoted to the C++ Standard Library.]] {{Main|C++ Standard Library}} The C++ [[standardization|standard]] consists of two parts: the core language and the standard library. C++ programmers expect the latter on every major implementation of C++; it includes aggregate types ([[sequence container (C++)#Vector|vectors]], lists, maps, sets, queues, stacks, arrays, tuples), [[algorithm]]s (find, [[Foreach loop|for_each]], [[Binary search algorithm|binary_search]], random_shuffle, etc.), input/output facilities ([[iostream]], for reading from and writing to the console and files), filesystem library, localisation support, [[smart pointers]] for automatic memory management, [[regular expression]] support, [[multithreading (software)|multi-threading]] library, atomics support (allowing a variable to be read or written to by at most one thread at a time without any external synchronisation), time utilities (measurement, getting current time, etc.), a system for converting error reporting that does not use C++ [[exception handling|exceptions]] into C++ exceptions, a [[random number generator]], and a slightly modified version of the [[C standard library]] (to make it comply with the C++ type system). A large part of the C++ library is based on the [[Standard Template Library]] (STL). Useful tools provided by the STL include [[container (data structure)|container]]s as the collections of objects (such as [[array data structure|vector]]s and [[linked list|lists]]), [[iterator]]s that provide array-like access to containers, and [[algorithm]]s that perform operations such as searching and sorting. Furthermore, (multi)maps ([[associative array]]s) and (multi)sets are provided, all of which export compatible interfaces. Therefore, using templates it is possible to write generic algorithms that work with any container or on any sequence defined by iterators. As in C, the [[feature (software design)|feature]]s of the [[library (computing)|library]] may be accessed by using the <syntaxhighlight lang="C++" inline>#include</syntaxhighlight> [[directive (programming)|directive]] to include a [[standard header]]. The [[C++ Standard Library]] provides 105 standard headers, of which 27 are deprecated. With the introduction of [[Precompiled header#Modules|modules]] in [[C++20]], these headers may be accessed with <syntaxhighlight lang="C++" inline>import</syntaxhighlight>, and in [[C++23]], the entire standard library can now be directly imported as module itself, with <syntaxhighlight lang="C++" inline>import std;</syntaxhighlight>. Currently, the C++ standard library provides two modules, <code>std</code> and <code>std.compat</code> (a compatibility module for <code>std</code> which exports C standard library facilities into the global namespace). The standard incorporates the STL that was originally designed by [[Alexander Stepanov]], who experimented with generic algorithms and containers for many years. When he started with C++, he finally found a language where it was possible to create generic algorithms (e.g., STL sort) that perform even better than, for example, the C standard library qsort, thanks to C++ features like using inlining and compile-time binding instead of function pointers. The standard does not refer to it as "STL", as it is merely a part of the standard library, but the term is still widely used to distinguish it from the rest of the standard library (input/output streams, internationalization, diagnostics, the C library subset, etc.).<ref>{{cite web |url=http://www.stlport.org/resources/StepanovUSA.html |author=Graziano Lo Russo |title=An Interview with A. Stepanov |year=2008 |access-date=8 October 2015 |website=stlport.org |archive-date=4 March 2009 |archive-url=https://web.archive.org/web/20090304120628/http://www.stlport.org/resources/StepanovUSA.html |url-status=live }}</ref> Most C++ compilers, and all major ones, provide a standards-conforming implementation of the 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)