-
Notifications
You must be signed in to change notification settings - Fork 29
/
general.html
269 lines (238 loc) · 10.9 KB
/
general.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<cxx-clause id="introduction" number="none">
<h1>Introduction</h1>
<p>
In this document, the phrase <cxx-term>C++ Standard Library</cxx-term>
refers to the library described in ISO/IEC 14882:2020, clauses 16–32.
</p>
<p>
Clauses and subclauses in this document are annotated with a so-called stable name,
presented in square brackets next to the (sub)clause heading
(such as "[introduction]" for this clause).
Stable names aid in the discussion and evolution of this document
by serving as stable references to subclauses across editions
that are unaffected by changes of subclause numbering.
</p>
</cxx-clause>
<cxx-clause id="general.scope" number="1">
<h1>Scope</h1>
<p>This document describes extensions to the C++
Standard Library (<cxx-ref to="general.references"></cxx-ref>).
These extensions are classes and functions that are likely to be
used widely within a program and/or on the interface boundaries
between libraries written by different organizations.</p>
<p>Some of the library components in this document might be
considered for standardization in a future version of C++, but
they are not currently part of any C++ standard. Some of the
components in this document might never be
standardized, and others might be standardized in a substantially
changed form.</p>
<p>The goal of this document is to build more
widespread existing practice for an expanded C++ standard
library. It gives advice on extensions to those vendors who wish
to provide them.</p>
</cxx-clause>
<cxx-clause id="general.references">
<h1>Normative references</h1>
<p>The following documents are referred to in the text
in such a way that some or all of their content
constitutes requirements of this document.
For dated references, only the edition cited applies.
For undated references, the latest edition
of the referenced document (including any amendments) applies.</p>
<ul>
<li>ISO/IEC 14882:2020, <cite>Programming Languages — C++</cite>
</ul>
<cxx-foreign-index id="cxx" src="cxx20_index.json" name="C++20"></cxx-foreign-index></li>
</cxx-clause>
<cxx-clause id="general.terms">
<h1>Terms and definitions</h1>
<p>For the purposes of this document, the terms and definitions
given in ISO/IEC 14882:2020 apply.</p>
<p>ISO and IEC maintain terminology databases for use in standardization at the following addresses:</p>
<ul>
<li>ISO Online browsing platform: available at <a href="https://www.iso.org/obp">https://www.iso.org/obp</a></li>
<li>IEC Electropedia: available at <a href="https://www.electropedia.org/">https://www.electropedia.org/</a></li>
</ul>
</cxx-clause>
<cxx-clause id="general">
<h1>General principles</h1>
<cxx-section id="general.namespaces">
<h1>Namespaces, headers, and modifications to standard classes</h1>
<p>Since the extensions described in this document
are experimental and not part of the C++ standard library, they
should not be declared directly within namespace
<code>std</code>.
Unless otherwise specified, all components described in this document either:
</p>
<ul>
<li>modify an existing interface in the C++ Standard Library in-place,</li>
<li>
are declared in a namespace whose name appends <code>::experimental::fundamentals_v3</code>
to a namespace defined in the C++ Standard Library,
such as <code>std</code> or <code>std::chrono</code>, or
</li>
<li>
are declared in a subnamespace of a namespace described in the previous bullet,
whose name is not the same as an existing subnamespace of namespace <code>std</code>.
</li>
</ul>
<cxx-example>
This document does not define <code>std::experimental::fundamentals_v3::pmr</code>
because the C++ Standard Library defines <code>std::pmr</code>.
</cxx-example>
<p>Each header described in this document shall import the contents of
<code>std::experimental::fundamentals_v3</code> into
<code>std::experimental</code> as if by</p>
<pre><code>namespace std::experimental::inline fundamentals_v3 {}</code></pre>
<p>
This document also describes some experimental modifications to existing interfaces in the C++ Standard Library.
</p>
<p>Unless otherwise specified, references to other entities
described in this document are assumed to be
qualified with <code>std::experimental::fundamentals_v3::</code>,
and references to entities described in the standard are assumed
to be qualified with <code>std::</code>.</p>
<p>Extensions that are expected to eventually be added to an
existing header <code><meow></code> are provided inside the
<code><experimental/meow></code> header, which shall include
the standard contents of <code><meow></code> as if by</p>
<pre><code>#include <meow></code></pre>
<p>New headers are also provided in the
<code><experimental/></code> directory, but without such an
<code>#include</code>.</p>
<table is="cxx-table" id="tab.cxx.headers" class="list" columns="3">
<caption>C++ library headers</caption>
<tr><td>
<ul>
<li><code><experimental/algorithm></code></li>
<li><code><experimental/functional></code></li>
<li><code><experimental/future></code></li>
<li><code><experimental/iterator></code></li>
<li><code><experimental/memory></code></li>
<li><code><experimental/memory_resource></code></li>
<li><code><experimental/propagate_const></code></li>
<li><code><experimental/random></code></li>
<li><code><experimental/scope></code></li>
<li><code><experimental/type_traits></code></li>
<li><code><experimental/utility></code></li>
</ul>
</td></tr>
</table>
<p><cxx-note>This is the last in a series of revisions of this document
planned by the C++ committee; while there are no plans to resume the series,
any future versions will define their contents in
<code>std::experimental::fundamentals_v4</code>,
<code>std::experimental::fundamentals_v5</code>, etc., with the
most recent implemented version inlined into
<code>std::experimental</code>.</cxx-note></p>
</cxx-section>
<cxx-section id="general.feature.test">
<h1>Feature-testing recommendations</h1>
<p>
For the sake of improved portability between partial implementations of various C++ standards,
implementers and programmers are recommended to follow the guidelines in this section concerning feature-test macros.
<cxx-note>Standing document
<a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a>
makes similar recommendations for ISO/IEC 14882:2020.</cxx-note>
</p>
<p>
Implementers who provide a new standard feature should define a macro with the recommended name,
in the same circumstances under which the feature is available (for example, taking into account relevant command-line options),
to indicate the presence of support for that feature.
Implementers should define that macro with the value specified in
the most recent version of this document that they have implemented.
The recommended macro name is "<code>__cpp_lib_experimental_</code>" followed by the string in the "Macro Name Suffix" column.
</p>
<p>
Programmers who wish to determine whether a feature is available in an implementation should base that determination on
the presence of the header (determined with <code>__has_include(<header/name>)</code>) and
the state of the macro with the recommended name.
(The absence of a tested feature may result in a program with decreased functionality, or the relevant functionality may be provided in a different way.
A program that strictly depends on support for a feature can just try to use the feature unconditionally;
presumably, on an implementation lacking necessary support, translation will fail.)
</p>
<table is="cxx-table" class="column-rules">
<caption>Significant features in this document</caption>
<thead>
<tr>
<th>Feature</th>
<th>Primary Section</th>
<th>Macro Name Suffix</th>
<th>Value</th>
<th>Header</th>
</tr>
</thead>
<!-- These rows are in the same order as their feature appears in this document. -->
<tr>
<td>Const-propagating wrapper</th>
<td><cxx-ref to="propagate_const"></cxx-ref></th>
<td><code>propagate_const</code></th>
<td>201505</th>
<td><code><experimental/propagate_const></code></th>
</tr>
<tr>
<td>Generic scope guard and RAII wrapper</th>
<td><cxx-ref to="scopeguard"></cxx-ref></th>
<td><code>scope</code></th>
<td>201902</th>
<td><code><experimental/scope></code></th>
</tr>
<tr>
<td>Invocation type traits</td>
<td><cxx-ref to="meta.trans.other"></cxx-ref></td>
<td><code>invocation_type</code></td>
<td>201406</td>
<td><code><experimental/type_traits></code></td>
</tr>
<tr>
<td>Detection metaprograms</td>
<td><cxx-ref to="meta.detect"></cxx-ref></td>
<td><code>detect</code></td>
<td>201505</td>
<td><code><experimental/type_traits></code></td>
</tr>
<tr>
<td>Polymorphic allocator for <code>std::function</code></td>
<td><cxx-ref to="func.wrap.func"></cxx-ref></td>
<td><code>function_polymorphic_allocator</code></td>
<td>202211</td>
<td><code><experimental/functional></code></td>
</tr>
<tr>
<td>Polymorphic memory resources</td>
<td><cxx-ref to="memory.resource.syn"></cxx-ref></td>
<td><code>memory_resources</code></td>
<td>201803</td>
<td><code><experimental/memory_resouce></code></td>
</tr>
<tr>
<td>Non-owning pointer wrapper</th>
<td><cxx-ref to="memory.observer.ptr"></cxx-ref></th>
<td><code>observer_ptr</code></th>
<td>201411</th>
<td><code><experimental/memory></code></th>
</tr>
<tr>
<td>Delimited iterators</td>
<td><cxx-ref to="iterator.ostream.joiner"></cxx-ref></td>
<td><code>ostream_joiner</code></td>
<td>201411</td>
<td><code><experimental/iterator></code></td>
</tr>
<tr>
<td>Random sampling</td>
<td><cxx-ref to="alg.random.sample"></cxx-ref></td>
<td><code>sample</code></td>
<td>201402</td>
<td><code><experimental/algorithm></code></td>
</tr>
<tr>
<td>Replacement for <code>std::rand</code></td>
<td><cxx-ref to="rand.randint"></cxx-ref></td>
<td><code>randint</code></td>
<td>201511</td>
<td><code><experimental/random></code></td>
</tr>
</table>
</cxx-section>
</cxx-clause>