From Jason Turner

[diff.cpp23]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1ryh52fa/{from.md → to.md} +384 -0
tmp/tmp1ryh52fa/{from.md → to.md} RENAMED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## C++ and ISO C++23 <a id="diff.cpp23">[[diff.cpp23]]</a>
2
+
3
+ ### General <a id="diff.cpp23.general">[[diff.cpp23.general]]</a>
4
+
5
+ Subclause [[diff.cpp23]] lists the differences between C++ and ISO
6
+ C++23, by the chapters of this document.
7
+
8
+ ### [[lex]]: lexical conventions <a id="diff.cpp23.lex">[[diff.cpp23.lex]]</a>
9
+
10
+ **Change:** New operator `^^`. **Rationale:** Required for new features.
11
+ **Effect on original feature:** Valid C++23 code that contains two
12
+ consecutive `^` tokens can be ill-formed in this revision of C++.
13
+
14
+ [*Example 1*:
15
+
16
+ ``` cpp
17
+ struct C { int operator^(int); };
18
+ int operator^(int (C::*p)(int), C);
19
+ int i = &C::operator^^C{}; // ill-formed; previously well-formed
20
+ ```
21
+
22
+ — *end example*]
23
+
24
+ **Change:** New keywords. **Rationale:** Required for new features.
25
+
26
+ - The `contract_assert` keyword is added to introduce a contract
27
+ assertion through an *assertion-statement* [[stmt.contract.assert]].
28
+
29
+ **Effect on original feature:** Valid C++23 code using `contract_assert`
30
+ as an identifier is not valid in this revision of C++.
31
+
32
+ ### [[expr]]: expressions <a id="diff.cpp23.expr">[[diff.cpp23.expr]]</a>
33
+
34
+ **Change:** Operations mixing a value of an enumeration type and a value
35
+ of a different enumeration type or of a floating-point type are no
36
+ longer valid. **Rationale:** Reinforcing type safety. **Effect on
37
+ original feature:** A valid C++23 program that performs operations
38
+ mixing a value of an enumeration type and a value of a different
39
+ enumeration type or of a floating-point type is ill-formed.
40
+
41
+ [*Example 1*:
42
+
43
+ ``` cpp
44
+ enum E1 { e };
45
+ enum E2 { f };
46
+ bool b = e <= 3.7; // ill-formed; previously well-formed
47
+ int k = f - e; // ill-formed; previously well-formed
48
+ auto x = true ? e : f; // ill-formed; previously well-formed
49
+ ```
50
+
51
+ — *end example*]
52
+
53
+ **Change:** Comparing two objects of array type is no longer valid.
54
+ **Rationale:** The old behavior was confusing since it compared not the
55
+ contents of the two arrays, but their addresses. **Effect on original
56
+ feature:** A valid C++23 program directly comparing two array objects is
57
+ rejected as ill-formed in this document.
58
+
59
+ [*Example 2*:
60
+
61
+ ``` cpp
62
+ int arr1[5];
63
+ int arr2[5];
64
+ bool same = arr1 == arr2; // ill-formed; previously well-formed
65
+ bool idem = arr1 == +arr2; // compare addresses
66
+ bool less = arr1 < +arr2; // compare addresses, unspecified result
67
+ ```
68
+
69
+ — *end example*]
70
+
71
+ **Change:** Calling `delete` on a pointer to an incomplete class is
72
+ ill-formed. **Rationale:** Reduce undefined behavior. **Effect on
73
+ original feature:** A valid C++23 program that calls `delete` on an
74
+ incomplete class type is ill-formed.
75
+
76
+ [*Example 3*:
77
+
78
+ ``` cpp
79
+ struct S;
80
+
81
+ void f(S *p) {
82
+ delete p; // ill-formed; previously well-formed
83
+ }
84
+
85
+ struct S {};
86
+ ```
87
+
88
+ — *end example*]
89
+
90
+ ### [[dcl]]: declarations <a id="diff.cpp23.dcl.dcl">[[diff.cpp23.dcl.dcl]]</a>
91
+
92
+ **Change:** Introduction of `trivially_relocatable_if_eligible` and
93
+ `replaceable_if_eligible` as identifiers with special meaning
94
+ [[lex.name]]. **Rationale:** Support declaration of trivially
95
+ relocatable and replaceable types [[class.prop]]. **Effect on original
96
+ feature:** Valid C++23 code can become ill-formed.
97
+
98
+ [*Example 1*:
99
+
100
+ ``` cpp
101
+ struct C {};
102
+ struct C replaceable_if_eligible {}; // was well-formed (new variable replaceable_if_eligible)
103
+ // now ill-formed (redefines C)
104
+ ```
105
+
106
+ — *end example*]
107
+
108
+ **Change:** Pointer comparisons between `initializer_list` objects’
109
+ backing arrays are unspecified. **Rationale:** Permit the implementation
110
+ to store backing arrays in static read-only memory. **Effect on original
111
+ feature:** Valid C++23 code that relies on the result of pointer
112
+ comparison between backing arrays may change behavior.
113
+
114
+ [*Example 2*:
115
+
116
+ ``` cpp
117
+ bool ne(std::initializer_list<int> a, std::initializer_list<int> b) {
118
+ return a.begin() != b.begin() + 1;
119
+ }
120
+ bool b = ne({2,3}, {1,2,3}); // unspecified result; previously false
121
+ ```
122
+
123
+ — *end example*]
124
+
125
+ **Change:** Previously, `T...[n]` would declare a pack of function
126
+ parameters. `T...[n]` is now a *pack-index-specifier*. **Rationale:**
127
+ Improve the handling of packs. **Effect on original feature:** Valid
128
+ C++23 code that declares a pack of parameters without specifying a
129
+ *declarator-id* becomes ill-formed.
130
+
131
+ [*Example 3*:
132
+
133
+ ``` cpp
134
+ template <typename... T>
135
+ void f(T... [1]);
136
+ template <typename... T>
137
+ void g(T... ptr[1]);
138
+ int main() {
139
+ f<int, double>(nullptr, nullptr); // ill-formed, previously void f<int, double>(int [1], double [1])
140
+ g<int, double>(nullptr, nullptr); // ok
141
+ }
142
+ ```
143
+
144
+ — *end example*]
145
+
146
+ **Change:** New token `:]`. **Rationale:** Required for new features.
147
+ **Effect on original feature:** Valid C++23 code that contained an
148
+ *attribute-specifier* with an *attribute-using-prefix* but no attributes
149
+ and no whitespace is ill-formed in this revision of C++.
150
+
151
+ [*Example 4*:
152
+
153
+ ``` cpp
154
+ struct [[using CC:]] C; // ill-formed; previously well-formed
155
+ struct [[using DD: ]] D; // OK
156
+ ```
157
+
158
+ — *end example*]
159
+
160
+ ### [[temp]]: templates <a id="diff.cpp23.temp">[[diff.cpp23.temp]]</a>
161
+
162
+ **Change:** Some atomic constraints become fold expanded constraints.
163
+ **Rationale:** Permit the subsumption of fold expressions. **Effect on
164
+ original feature:** Valid C++23 code may become ill-formed.
165
+
166
+ [*Example 1*:
167
+
168
+ ``` cpp
169
+ template <typename ...V> struct A;
170
+ struct S {
171
+ static constexpr int compare(const S&) { return 1; }
172
+ };
173
+
174
+ template <typename ...T, typename ...U>
175
+ void f(A<T ...> *, A<U ...> *)
176
+ requires (T::compare(U{}) && ...); // was well-formed (atomic constraint of type bool),
177
+ // now ill-formed (results in an atomic constraint of type int)
178
+ void g(A<S, S> *ap) {
179
+ f(ap, ap);
180
+ }
181
+ ```
182
+
183
+ — *end example*]
184
+
185
+ **Change:** Template argument deduction from overload sets succeeds in
186
+ more cases. **Rationale:** Allow consideration of constraints to
187
+ disambiguate overload sets used as parameters in function calls.
188
+ **Effect on original feature:** Valid C++23 code may become ill-formed.
189
+
190
+ [*Example 2*:
191
+
192
+ ``` cpp
193
+ template <typename T>
194
+ void f(T &&, void (*)(T &&));
195
+
196
+ void g(int &); // #1
197
+ inline namespace A {
198
+ void g(short &&); // #2
199
+ }
200
+ inline namespace B {
201
+ void g(short &&); // #3
202
+ }
203
+
204
+ void q() {
205
+ int x;
206
+ f(x, g); // ill-formed; previously well-formed, deducing T = int&
207
+ }
208
+ ```
209
+
210
+ There is no change to the applicable deduction rules for the individual
211
+ `g` candidates: Type deduction from \#1 does not succeed; type
212
+ deductions from \#2 and \#3 both succeed.
213
+
214
+ — *end example*]
215
+
216
+ ### [[library]]: library introduction <a id="diff.cpp23.library">[[diff.cpp23.library]]</a>
217
+
218
+ **Change:** New headers. **Rationale:** New functionality. **Effect on
219
+ original feature:** The following C++ headers are new: `<contracts>`,
220
+ `<debugging>`, `<hazard_pointer>`, `<hive>`, `<inplace_vector>`,
221
+ `<linalg>`, `<meta>`, `<rcu>`, `<simd>`, `<stdbit.h>`, `<stdckdint.h>`,
222
+ and `<text_encoding>`. Valid C++23 code that `#include`s headers with
223
+ these names may be invalid in this revision of C++.
224
+
225
+ **Change:** Additional restrictions on macro names. **Rationale:** Avoid
226
+ hard to diagnose or non-portable constructs. **Effect on original
227
+ feature:** Names of special identifiers may not be used as macro names.
228
+ Valid C++23 code that defines `replaceable_if_eligible` or
229
+ `trivially_relocatable_if_eligible` as macros is invalid in this
230
+ revision of C++.
231
+
232
+ ### [[mem]]: memory management library <a id="diff.cpp23.mem">[[diff.cpp23.mem]]</a>
233
+
234
+ **Change:** Calling `realloc` with a non-null pointer and zero size has
235
+ erroneous behavior. **Rationale:** The C standard library does not
236
+ define this behavior. **Effect on original feature:** Valid C++23 code
237
+ that calls `realloc` with a non-null pointer and a size of zero is
238
+ erroneous and may change behavior.
239
+
240
+ ### [[containers]]: containers library <a id="diff.cpp23.containers">[[diff.cpp23.containers]]</a>
241
+
242
+ **Change:** `span<const T>` is constructible from `initializer_list<T>`.
243
+ **Rationale:** Permit passing a braced initializer list to a function
244
+ taking `span`. **Effect on original feature:** Valid C++23 code that
245
+ relies on the lack of this constructor may refuse to compile, or change
246
+ behavior in this revision of C++.
247
+
248
+ [*Example 1*:
249
+
250
+ ``` cpp
251
+ void one(pair<int, int>); // #1
252
+ void one(span<const int>); // #2
253
+ void t1() { one({1, 2}); } // ambiguous between #1 and #2; previously called #1
254
+
255
+ void two(span<const int, 2>);
256
+ void t2() { two({{1, 2}}); } // ill-formed; previously well-formed
257
+
258
+ void *a[10];
259
+ int x = span<void* const>{a, 0}.size(); // x is 2; previously 0
260
+ any b[10];
261
+ int y = span<const any>{b, b + 10}.size(); // y is 2; previously 10
262
+ ```
263
+
264
+ — *end example*]
265
+
266
+ ### [[strings]]: strings library <a id="diff.cpp23.strings">[[diff.cpp23.strings]]</a>
267
+
268
+ **Change:** Output of floating-point overloads of `to_string` and
269
+ `to_wstring`. **Rationale:** Prevent loss of information and improve
270
+ consistency with other formatting facilities. **Effect on original
271
+ feature:** `to_string` and `to_wstring` function calls that take
272
+ floating-point arguments may produce a different output.
273
+
274
+ [*Example 1*:
275
+
276
+ ``` cpp
277
+ auto s = std::to_string(1e-7); // "1e-07"
278
+ // previously "0.000000" with '.' possibly
279
+ // changed according to the global C locale
280
+ ```
281
+
282
+ — *end example*]
283
+
284
+ ### [[input.output]]: input/output library <a id="diff.cpp23.io">[[diff.cpp23.io]]</a>
285
+
286
+ **Change:** Overloaded `std::basic_istream<char, traits>::ignore`.
287
+ **Rationale:** Allow `char` values to be used as delimiters. **Effect on
288
+ original feature:** Calls to `istream::ignore` with a second argument of
289
+ `char` type can change behavior. Calls to `istream::ignore` with a
290
+ second argument that is neither `int` nor `char` type can become
291
+ ill-formed.
292
+
293
+ [*Example 1*:
294
+
295
+ ``` cpp
296
+ std::istringstream in("\xF0\x9F\xA4\xA1 Clown Face");
297
+ in.ignore(100, '\xA1'); // ignore up to '{xA1'} delimiter,
298
+ // previously might have ignored to EOF
299
+ in.ignore(100, -1L); // ambiguous overload,
300
+ // previously equivalent to (int)-1L
301
+ ```
302
+
303
+ — *end example*]
304
+
305
+ ### [[depr]]: compatibility features <a id="diff.cpp23.depr">[[diff.cpp23.depr]]</a>
306
+
307
+ **Change:** Remove the type alias `allocator<T>::is_always_equal`.
308
+ **Rationale:** Non-empty allocator classes derived from `allocator`
309
+ needed to explicitly define an `is_always_equal` member type so that
310
+ `allocator_traits` would not use the one from the allocator base class.
311
+ **Effect on original feature:** It is simpler to correctly define an
312
+ allocator class with an allocator base class.
313
+
314
+ [*Example 1*:
315
+
316
+ ``` cpp
317
+ template <class T>
318
+ struct MyAlloc : allocator<T> {
319
+ int tag;
320
+ };
321
+
322
+ static_assert(!allocator_traits<MyAlloc<int>>::is_always_equal); // Error in C++23{},
323
+ // OK in C++26{}
324
+ ```
325
+
326
+ — *end example*]
327
+
328
+ **Change:** Removal of atomic access API for `shared_ptr` objects.
329
+ **Rationale:** The old behavior was brittle. `shared_ptr` objects using
330
+ the old API were not protected by the type system, and certain
331
+ interactions with code not using this API would, in some cases, silently
332
+ produce undefined behavior. A complete type-safe replacement is provided
333
+ in the form of `atomic<shared_ptr<T>>`. **Effect on original feature:**
334
+ A valid C++23 program that relies on the presence of the removed
335
+ functions may fail to compile.
336
+
337
+ **Change:** Remove the `basic_string::reserve()` overload with no
338
+ parameters. **Rationale:** The overload of `reserve` with no parameters
339
+ is redundant. The `shrink_to_fit` member function can be used instead.
340
+ **Effect on original feature:** A valid C++23 program that calls
341
+ `reserve()` on a `basic_string` object may fail to compile. The old
342
+ functionality can be achieved by calling `shrink_to_fit()` instead, or
343
+ the function call can be safely eliminated with no side effects.
344
+
345
+ **Change:** Remove header `<codecvt>` and all its contents.
346
+ **Rationale:** The header has been deprecated for the previous three
347
+ editions of this document and no longer implements the current Unicode
348
+ standard, supporting only the obsolete UCS-2 encoding. Ongoing support
349
+ is at implementer’s discretion, exercising freedoms granted by
350
+ [[zombie.names]]. **Effect on original feature:** A valid C++23 program
351
+ `#include`-ing the header or importing the header unit may fail to
352
+ compile. Code that uses any of the following names by importing the
353
+ standard library modules may fail to compile:
354
+
355
+ - `codecvt_mode`,
356
+ - `codecvt_utf16`,
357
+ - `codecvt_utf8`,
358
+ - `codecvt_utf8_utf16`,
359
+ - `consume_header`,
360
+ - `generate_header`, and
361
+ - `little_endian`.
362
+
363
+ **Change:** Remove header `<strstream>` and all its contents.
364
+ **Rationale:** The header has been deprecated since the original C++
365
+ standard; the `<spanstream>` header provides an updated, safer facility.
366
+ Ongoing support is at implementer’s discretion, exercising freedoms
367
+ granted by [[zombie.names]]. **Effect on original feature:** A valid
368
+ C++23 program `#include`-ing the header or importing the header unit may
369
+ become ill-formed. Code that uses any of the following classes by
370
+ importing one of the standard library modules may become ill-formed:
371
+
372
+ - `istrstream`
373
+ - `ostrstream`
374
+ - `strstream`
375
+ - `strstreambuf`
376
+
377
+ **Change:** Remove convenience interfaces `wstring_convert` and
378
+ `wbuffer_convert`. **Rationale:** These features were underspecified
379
+ with no clear error reporting mechanism and were deprecated for the last
380
+ three editions of this document. Ongoing support is at implementer’s
381
+ discretion, exercising freedoms granted by [[zombie.names]]. **Effect on
382
+ original feature:** A valid C++23 program using these interfaces may
383
+ become ill-formed.
384
+