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
(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 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. |}
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)