tmp/tmp6vhgh_2x/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
### Library contents and organization <a id="organization">[[organization]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
[[contents]] describes the entities and macros defined in the C++
|
| 4 |
standard library. [[headers]] lists the standard library headers and
|
| 5 |
some constraints on those headers. [[compliance]] lists requirements for
|
| 6 |
a freestanding implementation of the C++ standard library.
|
| 7 |
|
|
@@ -11,19 +13,40 @@ The C++ standard library provides definitions for the entities and
|
|
| 11 |
macros described in the synopses of the C++ standard library headers
|
| 12 |
[[headers]], unless otherwise specified.
|
| 13 |
|
| 14 |
All library entities except `operator new` and `operator delete` are
|
| 15 |
defined within the namespace `std` or namespaces nested within namespace
|
| 16 |
-
`std`.[^12]
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
#### Headers <a id="headers">[[headers]]</a>
|
| 27 |
|
| 28 |
Each element of the C++ standard library is declared or defined (as
|
| 29 |
appropriate) in a *header*.[^14]
|
|
@@ -37,12 +60,12 @@ headers shown in [[headers.cpp.c]]. [^15]
|
|
| 37 |
The headers listed in [[headers.cpp]], or, for a freestanding
|
| 38 |
implementation, the subset of such headers that are provided by the
|
| 39 |
implementation, are collectively known as the
|
| 40 |
*importable C++ library headers*.
|
| 41 |
|
| 42 |
-
[*Note 1*: Importable C++ library headers can be imported
|
| 43 |
-
|
| 44 |
|
| 45 |
[*Example 1*:
|
| 46 |
|
| 47 |
``` cpp
|
| 48 |
import <vector>; // imports the <vector> header unit
|
|
@@ -74,12 +97,12 @@ Names that are defined as functions in C shall be defined as functions
|
|
| 74 |
in the C++ standard library.[^16]
|
| 75 |
|
| 76 |
Identifiers that are keywords or operators in C++ shall not be defined
|
| 77 |
as macros in C++ standard library headers.[^17]
|
| 78 |
|
| 79 |
-
[[
|
| 80 |
-
using the `name.h` (C header) form in a C++ program.[^18]
|
| 81 |
|
| 82 |
Annex K of the C standard describes a large number of functions, with
|
| 83 |
associated types and macros, which “promote safer, more secure
|
| 84 |
programming” than many of the traditional C library functions. The names
|
| 85 |
of the functions have a suffix of `_s`; most of them provide the same
|
|
@@ -91,13 +114,54 @@ global namespace. (None of them is declared in namespace `std`.)
|
|
| 91 |
|
| 92 |
[[c.annex.k.names]] lists the Annex K names that may be declared in some
|
| 93 |
header. These names are also subject to the restrictions of
|
| 94 |
[[macro.names]].
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
#### Freestanding implementations <a id="compliance">[[compliance]]</a>
|
| 97 |
|
| 98 |
-
Two kinds of implementations are defined:
|
| 99 |
[[intro.compliance]]; the kind of the implementation is
|
| 100 |
*implementation-defined*. For a hosted implementation, this document
|
| 101 |
describes the set of available headers.
|
| 102 |
|
| 103 |
A freestanding implementation has an *implementation-defined* set of
|
|
@@ -105,35 +169,35 @@ headers. This set shall include at least the headers shown in
|
|
| 105 |
[[headers.cpp.fs]].
|
| 106 |
|
| 107 |
**Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
|
| 108 |
|
| 109 |
| Subclause | | Header |
|
| 110 |
-
| ---------------------- | ------------------------- | ------------------------------------------------ |
|
| 111 |
-
| [[support.types]] |
|
| 112 |
| [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
|
| 113 |
-
| [[cstdint]]
|
| 114 |
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 115 |
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 116 |
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 117 |
| [[support.srcloc]] | Source location | `<source_location>` |
|
| 118 |
| [[support.exception]] | Exception handling | `<exception>` |
|
| 119 |
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 120 |
| [[cmp]] | Comparisons | `<compare>` |
|
| 121 |
| [[support.coroutine]] | Coroutines support | `<coroutine>` |
|
| 122 |
| [[support.runtime]] | Other runtime support | `<cstdarg>` |
|
| 123 |
| [[concepts]] | Concepts library | `<concepts>` |
|
| 124 |
-
| [[
|
| 125 |
| [[bit]] | Bit manipulation | `<bit>` |
|
| 126 |
| [[atomics]] | Atomics | `<atomic>` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
`<atomic>` shall meet the same requirements as for a hosted
|
| 133 |
-
implementation except that support for always lock-free integral atomic
|
| 134 |
-
types [[atomics.lockfree]] is *implementation-defined*, and whether or
|
| 135 |
-
not the type aliases `atomic_signed_lock_free` and
|
| 136 |
-
`atomic_unsigned_lock_free` are defined [[atomics.alias]] is
|
| 137 |
-
*implementation-defined*. The other headers listed in this table shall
|
| 138 |
-
meet the same requirements as for a hosted implementation.
|
| 139 |
|
|
|
|
| 1 |
### Library contents and organization <a id="organization">[[organization]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="organization.general">[[organization.general]]</a>
|
| 4 |
+
|
| 5 |
[[contents]] describes the entities and macros defined in the C++
|
| 6 |
standard library. [[headers]] lists the standard library headers and
|
| 7 |
some constraints on those headers. [[compliance]] lists requirements for
|
| 8 |
a freestanding implementation of the C++ standard library.
|
| 9 |
|
|
|
|
| 13 |
macros described in the synopses of the C++ standard library headers
|
| 14 |
[[headers]], unless otherwise specified.
|
| 15 |
|
| 16 |
All library entities except `operator new` and `operator delete` are
|
| 17 |
defined within the namespace `std` or namespaces nested within namespace
|
| 18 |
+
`std`.[^12]
|
| 19 |
+
|
| 20 |
+
It is unspecified whether names declared in a specific namespace are
|
| 21 |
+
declared directly in that namespace or in an inline namespace inside
|
| 22 |
+
that namespace.[^13]
|
| 23 |
+
|
| 24 |
+
Whenever an unqualified name other than `swap`, `make_error_code`, or
|
| 25 |
+
`make_error_condition` is used in the specification of a declaration `D`
|
| 26 |
+
in [[support]] through [[thread]] or [[depr]], its meaning is
|
| 27 |
+
established as-if by performing unqualified name lookup
|
| 28 |
+
[[basic.lookup.unqual]] in the context of `D`.
|
| 29 |
+
|
| 30 |
+
[*Note 1*: Argument-dependent lookup is not performed. — *end note*]
|
| 31 |
+
|
| 32 |
+
Similarly, the meaning of a *qualified-id* is established as-if by
|
| 33 |
+
performing qualified name lookup [[basic.lookup.qual]] in the context of
|
| 34 |
+
`D`.
|
| 35 |
+
|
| 36 |
+
[*Example 1*: The reference to `is_array_v` in the specification of
|
| 37 |
+
`std::to_array` [[array.creation]] refers to
|
| 38 |
+
`::std::is_array_v`. — *end example*]
|
| 39 |
+
|
| 40 |
+
[*Note 2*: Operators in expressions [[over.match.oper]] are not so
|
| 41 |
+
constrained; see [[global.functions]]. — *end note*]
|
| 42 |
+
|
| 43 |
+
The meaning of the unqualified name `swap` is established in an overload
|
| 44 |
+
resolution context for swappable values [[swappable.requirements]]. The
|
| 45 |
+
meanings of the unqualified names `make_error_code` and
|
| 46 |
+
`make_error_condition` are established as-if by performing
|
| 47 |
+
argument-dependent lookup [[basic.lookup.argdep]].
|
| 48 |
|
| 49 |
#### Headers <a id="headers">[[headers]]</a>
|
| 50 |
|
| 51 |
Each element of the C++ standard library is declared or defined (as
|
| 52 |
appropriate) in a *header*.[^14]
|
|
|
|
| 60 |
The headers listed in [[headers.cpp]], or, for a freestanding
|
| 61 |
implementation, the subset of such headers that are provided by the
|
| 62 |
implementation, are collectively known as the
|
| 63 |
*importable C++ library headers*.
|
| 64 |
|
| 65 |
+
[*Note 1*: Importable C++ library headers can be imported
|
| 66 |
+
[[module.import]]. — *end note*]
|
| 67 |
|
| 68 |
[*Example 1*:
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
import <vector>; // imports the <vector> header unit
|
|
|
|
| 97 |
in the C++ standard library.[^16]
|
| 98 |
|
| 99 |
Identifiers that are keywords or operators in C++ shall not be defined
|
| 100 |
as macros in C++ standard library headers.[^17]
|
| 101 |
|
| 102 |
+
[[support.c.headers]], C standard library headers, describes the effects
|
| 103 |
+
of using the `name.h` (C header) form in a C++ program.[^18]
|
| 104 |
|
| 105 |
Annex K of the C standard describes a large number of functions, with
|
| 106 |
associated types and macros, which “promote safer, more secure
|
| 107 |
programming” than many of the traditional C library functions. The names
|
| 108 |
of the functions have a suffix of `_s`; most of them provide the same
|
|
|
|
| 114 |
|
| 115 |
[[c.annex.k.names]] lists the Annex K names that may be declared in some
|
| 116 |
header. These names are also subject to the restrictions of
|
| 117 |
[[macro.names]].
|
| 118 |
|
| 119 |
+
#### Modules <a id="std.modules">[[std.modules]]</a>
|
| 120 |
+
|
| 121 |
+
The C++ standard library provides the following *C++ library modules*.
|
| 122 |
+
|
| 123 |
+
The named module `std` exports declarations in namespace `std` that are
|
| 124 |
+
provided by the importable C++ library headers ([[headers.cpp]] or the
|
| 125 |
+
subset provided by a freestanding implementation) and the C++ headers
|
| 126 |
+
for C library facilities ([[headers.cpp.c]]). It additionally exports
|
| 127 |
+
declarations in the global namespace for the storage allocation and
|
| 128 |
+
deallocation functions that are provided by `<new>`.
|
| 129 |
+
|
| 130 |
+
The named module `std.compat` exports the same declarations as the named
|
| 131 |
+
module `std`, and additionally exports declarations in the global
|
| 132 |
+
namespace corresponding to the declarations in namespace `std` that are
|
| 133 |
+
provided by the C++ headers for C library facilities (
|
| 134 |
+
[[headers.cpp.c]]), except the explicitly excluded declarations
|
| 135 |
+
described in [[support.c.headers.other]].
|
| 136 |
+
|
| 137 |
+
It is unspecified to which module a declaration in the standard library
|
| 138 |
+
is attached.
|
| 139 |
+
|
| 140 |
+
[*Note 1*: Implementations are required to ensure that mixing
|
| 141 |
+
`#include` and `import` does not result in conflicting attachments
|
| 142 |
+
[[basic.link]]. — *end note*]
|
| 143 |
+
|
| 144 |
+
*Recommended practice:* Implementations should ensure such attachments
|
| 145 |
+
do not preclude further evolution or decomposition of the standard
|
| 146 |
+
library modules.
|
| 147 |
+
|
| 148 |
+
A declaration in the standard library denotes the same entity regardless
|
| 149 |
+
of whether it was made reachable through including a header, importing a
|
| 150 |
+
header unit, or importing a C++ library module.
|
| 151 |
+
|
| 152 |
+
*Recommended practice:* Implementations should avoid exporting any other
|
| 153 |
+
declarations from the C++ library modules.
|
| 154 |
+
|
| 155 |
+
[*Note 2*: Like all named modules, the C++ library modules do not make
|
| 156 |
+
macros visible [[module.import]], such as `assert` [[cassert.syn]],
|
| 157 |
+
`errno` [[cerrno.syn]], `offsetof` [[cstddef.syn]], and `va_arg`
|
| 158 |
+
[[cstdarg.syn]]. — *end note*]
|
| 159 |
+
|
| 160 |
#### Freestanding implementations <a id="compliance">[[compliance]]</a>
|
| 161 |
|
| 162 |
+
Two kinds of implementations are defined: hosted and freestanding
|
| 163 |
[[intro.compliance]]; the kind of the implementation is
|
| 164 |
*implementation-defined*. For a hosted implementation, this document
|
| 165 |
describes the set of available headers.
|
| 166 |
|
| 167 |
A freestanding implementation has an *implementation-defined* set of
|
|
|
|
| 169 |
[[headers.cpp.fs]].
|
| 170 |
|
| 171 |
**Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
|
| 172 |
|
| 173 |
| Subclause | | Header |
|
| 174 |
+
| ---------------------- | -------------------------------- | ------------------------------------------------ |
|
| 175 |
+
| [[support.types]] | Common definitions | `<cstddef>` |
|
| 176 |
| [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
|
| 177 |
+
| [[cstdint.syn]] | Integer types | `<cstdint>` |
|
| 178 |
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 179 |
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 180 |
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 181 |
| [[support.srcloc]] | Source location | `<source_location>` |
|
| 182 |
| [[support.exception]] | Exception handling | `<exception>` |
|
| 183 |
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 184 |
| [[cmp]] | Comparisons | `<compare>` |
|
| 185 |
| [[support.coroutine]] | Coroutines support | `<coroutine>` |
|
| 186 |
| [[support.runtime]] | Other runtime support | `<cstdarg>` |
|
| 187 |
| [[concepts]] | Concepts library | `<concepts>` |
|
| 188 |
+
| [[type.traits]] | Type traits | `<type_traits>` |
|
| 189 |
| [[bit]] | Bit manipulation | `<bit>` |
|
| 190 |
| [[atomics]] | Atomics | `<atomic>` |
|
| 191 |
+
| [[utility]] | Utility components | `<utility>` |
|
| 192 |
+
| [[tuple]] | Tuples | `<tuple>` |
|
| 193 |
+
| [[memory]] | Memory | `<memory>` |
|
| 194 |
+
| [[function.objects]] | Function objects | `<functional>` |
|
| 195 |
+
| [[ratio]] | Compile-time rational arithmetic | `<ratio>` |
|
| 196 |
+
| [[iterators]] | Iterators library | `<iterator>` |
|
| 197 |
+
| [[ranges]] | Ranges library | `<ranges>` |
|
| 198 |
|
| 199 |
|
| 200 |
+
For each of the headers listed in [[headers.cpp.fs]], a freestanding
|
| 201 |
+
implementation provides at least the freestanding items
|
| 202 |
+
[[freestanding.item]] declared in the header.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|