From Jason Turner

[diff.cpp17]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp02p5b3_3/{from.md → to.md} +82 -62
tmp/tmp02p5b3_3/{from.md → to.md} RENAMED
@@ -1,47 +1,41 @@
1
  ## C++ and ISO C++17 <a id="diff.cpp17">[[diff.cpp17]]</a>
2
 
3
- This subclause lists the differences between C++ and ISO C++17 (ISO/IEC
4
- 14882:2017, *Programming Languages — C++*), by the chapters of this
5
- document.
 
 
6
 
7
  ### [[lex]]: lexical conventions <a id="diff.cpp17.lex">[[diff.cpp17.lex]]</a>
8
 
9
  **Change:** New identifiers with special meaning. **Rationale:**
10
  Required for new features. **Effect on original feature:** Logical lines
11
  beginning with `module` or `import` may be interpreted differently in
12
- this International Standard.
13
-
14
- [*Example 1*:
15
 
16
  ``` cpp
17
  class module {};
18
  module m1; // was variable declaration; now module-declaration
19
  module *m2; // variable declaration
20
 
21
  class import {};
22
- import j1; // was variable declaration; now import-declaration
23
  ::import j2; // variable declaration
24
  ```
25
 
26
- — *end example*]
27
-
28
  **Change:** *header-name* tokens are formed in more contexts.
29
  **Rationale:** Required for new features. **Effect on original
30
  feature:** When the identifier `import` is followed by a `<` character,
31
- a *header-name* token may be formed.
32
-
33
- [*Example 2*:
34
 
35
  ``` cpp
36
  template<typename> class import {};
37
  import<int> f(); // ill-formed; previously well-formed
38
  ::import<int> g(); // OK
39
  ```
40
 
41
- — *end example*]
42
-
43
  **Change:** New keywords. **Rationale:** Required for new features.
44
 
45
  - The `char8_t` keyword is added to differentiate the types of ordinary
46
  and UTF-8 literals [[lex.string]].
47
  - The `concept` keyword is added to enable the definition of concepts
@@ -56,16 +50,17 @@ import<int> f(); // ill-formed; previously well-formed
56
  *requires-clause* [[temp.pre]] or a *requires-expression*
57
  [[expr.prim.req]].
58
 
59
  Valid C++17 code using `char8_t`, `concept`, `consteval`, `constinit`,
60
  `co_await`, `co_yield`, `co_return`, or `requires` as an identifier is
61
- not valid in this International Standard.
62
 
63
  **Change:** New operator `<=>`. **Rationale:** Necessary for new
64
  functionality. **Effect on original feature:** Valid C++17 code that
65
  contains a `<=` token immediately followed by a `>` token may be
66
- ill-formed or have different semantics in this International Standard:
 
67
 
68
  ``` cpp
69
  namespace N {
70
  struct X {};
71
  bool operator<=(X, X);
@@ -78,11 +73,11 @@ namespace N {
78
  Required for new features. The changed types enable function
79
  overloading, template specialization, and type deduction to distinguish
80
  ordinary and UTF-8 string and character literals. **Effect on original
81
  feature:** Valid C++17 code that depends on UTF-8 string literals having
82
  type “array of `const char`” and UTF-8 character literals having type
83
- “`char`” is not valid in this International Standard.
84
 
85
  ``` cpp
86
  const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*
87
  const char *ps = u8s; // ill-formed; previously well-formed
88
 
@@ -104,25 +99,22 @@ ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed.
104
  ### [[basic]]: basics <a id="diff.cpp17.basic">[[diff.cpp17.basic]]</a>
105
 
106
  **Change:** A pseudo-destructor call ends the lifetime of the object to
107
  which it is applied. **Rationale:** Increase consistency of the language
108
  model. **Effect on original feature:** Valid ISO C++17 code may be
109
- ill-formed or have undefined behavior in this International Standard.
110
-
111
- [*Example 1*:
112
 
113
  ``` cpp
114
  int f() {
115
  int a = 123;
116
  using T = int;
117
  a.~T();
118
  return a; // undefined behavior; previously returned 123
119
  }
120
  ```
121
 
122
- — *end example*]
123
-
124
  **Change:** Except for the initial release operation, a release sequence
125
  consists solely of atomic read-modify-write operations. **Rationale:**
126
  Removal of rarely used and confusing feature. **Effect on original
127
  feature:** If a `memory_order_release` atomic store is followed by a
128
  `memory_order_relaxed` store to the same variable by the same thread,
@@ -142,22 +134,23 @@ result in an odr-use.
142
  ### [[dcl.dcl]]: declarations <a id="diff.cpp17.dcl.dcl">[[diff.cpp17.dcl.dcl]]</a>
143
 
144
  **Change:** Unnamed classes with a typedef name for linkage purposes can
145
  contain only C-compatible constructs. **Rationale:** Necessary for
146
  implementability. **Effect on original feature:** Valid C++17 code may
147
- be ill-formed in this International Standard.
148
 
149
  ``` cpp
150
  typedef struct {
151
  void f() {} // ill-formed; previously well-formed
152
  } S;
153
  ```
154
 
155
  **Change:** A function cannot have different default arguments in
156
  different translation units. **Rationale:** Required for modules
157
  support. **Effect on original feature:** Valid C++17 code may be
158
- ill-formed in this International Standard, with no diagnostic required.
 
159
 
160
  ``` cpp
161
  // Translation unit 1
162
  int f(int a = 42);
163
  int g() { return f(); }
@@ -171,11 +164,12 @@ int main() { return g(); } // used to return 42
171
  **Change:** A class that has user-declared constructors is never an
172
  aggregate. **Rationale:** Remove potentially error-prone aggregate
173
  initialization which may apply notwithstanding the declared constructors
174
  of a class. **Effect on original feature:** Valid C++17 code that
175
  aggregate-initializes a type with a user-declared constructor may be
176
- ill-formed or have different semantics in this International Standard.
 
177
 
178
  ``` cpp
179
  struct A { // not an aggregate; previously an aggregate
180
  A() = delete;
181
  };
@@ -209,11 +203,11 @@ Y y{X{}}; // copy constructor call; previously aggregate-initializ
209
  ```
210
 
211
  **Change:** Boolean conversion from a pointer or pointer-to-member type
212
  is now a narrowing conversion. **Rationale:** Catches bugs. **Effect on
213
  original feature:** Valid C++17 code may fail to compile in this
214
- International Standard. For example:
215
 
216
  ``` cpp
217
  bool y[] = { "bc" }; // ill-formed; previously well-formed
218
  ```
219
 
@@ -223,11 +217,11 @@ bool y[] = { "bc" }; // ill-formed; previously well-formed
223
  immediately after an `explicit` *decl-specifier* in a constructor
224
  declaration. The *conversion-function-id* can no longer be used
225
  parenthesized immediately after an `explicit` *decl-specifier* in a
226
  conversion function declaration. **Rationale:** Necessary for new
227
  functionality. **Effect on original feature:** Valid C++17 code may fail
228
- to compile in this International Standard. For example:
229
 
230
  ``` cpp
231
  struct S {
232
  explicit (S)(const S&); // ill-formed; previously well-formed
233
  explicit (operator int)(); // ill-formed; previously well-formed
@@ -236,12 +230,12 @@ struct S {
236
  ```
237
 
238
  **Change:** A *simple-template-id* is no longer valid as the
239
  *declarator-id* of a constructor or destructor. **Rationale:** Remove
240
  potentially error-prone option for redundancy. **Effect on original
241
- feature:** Valid C++17 code may fail to compile in this International
242
- Standard. For example:
243
 
244
  ``` cpp
245
  template<class T>
246
  struct A {
247
  A<T>(); // error: simple-template-id not allowed for constructor
@@ -254,11 +248,11 @@ struct A {
254
  a constructor taking an rvalue reference to a type different from that
255
  of the returned expression. Function and catch-clause parameters can be
256
  thrown using move constructors. **Rationale:** Side effect of making it
257
  easier to write more efficient code that takes advantage of moves.
258
  **Effect on original feature:** Valid C++17 code may fail to compile or
259
- have different semantics in this International Standard. For example:
260
 
261
  ``` cpp
262
  struct base {
263
  base();
264
  base(base const &);
@@ -293,15 +287,16 @@ void g() {
293
  ### [[over]]: overloading <a id="diff.cpp17.over">[[diff.cpp17.over]]</a>
294
 
295
  **Change:** Equality and inequality expressions can now find reversed
296
  and rewritten candidates. **Rationale:** Improve consistency of equality
297
  with three-way comparison and make it easier to write the full
298
- complement of equality operations. **Effect on original feature:**
299
- Equality and inequality expressions between two objects of different
300
- types, where one is convertible to the other, could invoke a different
301
- operator. Equality and inequality expressions between two objects of the
302
- same type could become ambiguous.
 
303
 
304
  ``` cpp
305
  struct A {
306
  operator int() const;
307
  };
@@ -315,58 +310,80 @@ int check(A x, A y) {
315
  (10 == x) + // calls #1, previously selected #2
316
  (10 != x); // calls #1, previously selected #3
317
  }
318
  ```
319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  ### [[temp]]: templates <a id="diff.cpp17.temp">[[diff.cpp17.temp]]</a>
321
 
322
  **Change:** An *unqualified-id* that is followed by a `<` and for which
323
  name lookup finds nothing or finds a function will be treated as a
324
  *template-name* in order to potentially cause argument dependent lookup
325
  to be performed. **Rationale:** It was problematic to call a function
326
  template with an explicit template argument list via argument dependent
327
  lookup because of the need to have a template with the same name visible
328
  via normal lookup. **Effect on original feature:** Previously valid code
329
  that uses a function name as the left operand of a `<` operator would
330
- become ill-formed.
331
 
332
  ``` cpp
333
  struct A {};
334
  bool operator<(void (*fp)(), A);
335
  void f() {}
336
  int main() {
337
  A a;
338
  f < a; // ill-formed; previously well-formed
339
- (f) < a; // still well formed
340
  }
341
  ```
342
 
343
  ### [[except]]: exception handling <a id="diff.cpp17.except">[[diff.cpp17.except]]</a>
344
 
345
  **Change:** Remove `throw()` exception specification. **Rationale:**
346
  Removal of obsolete feature that has been replaced by `noexcept`.
347
  **Effect on original feature:** A valid C++17 function declaration,
348
  member function declaration, function pointer declaration, or function
349
  reference declaration that uses `throw()` for its exception
350
- specification will be rejected as ill-formed in this International
351
- Standard. It should simply be replaced with `noexcept` for no change of
352
- meaning since C++17.
353
 
354
  [*Note 1*: There is no way to write a function declaration that is
355
- non-throwing in this International Standard and is also non-throwing in
356
- C++03 except by using the preprocessor to generate a different token
357
- sequence in each case. — *end note*]
358
 
359
  ### [[library]]: library introduction <a id="diff.cpp17.library">[[diff.cpp17.library]]</a>
360
 
361
  **Change:** New headers. **Rationale:** New functionality. **Effect on
362
  original feature:** The following C++ headers are new: `<barrier>`,
363
  `<bit>`, `<charconv>`, `<compare>`, `<concepts>`, `<coroutine>`,
364
  `<format>`, `<latch>`, `<numbers>`, `<ranges>`, `<semaphore>`,
365
  `<source_location>`, `<span>`, `<stop_token>`, `<syncstream>`, and
366
  `<version>`. Valid C++17 code that `#include`s headers with these names
367
- may be invalid in this International Standard.
368
 
369
  **Change:** Remove vacuous C++ header files. **Rationale:** The empty
370
  headers implied a false requirement to achieve C compatibility with the
371
  C++ headers. **Effect on original feature:** A valid C++17 program that
372
  `#include`s any of the following headers may fail to compile:
@@ -384,14 +401,14 @@ To retain the same behavior:
384
 
385
  **Change:** Return types of `remove`, `remove_if`, and `unique` changed
386
  from `void` to `container::size_type`. **Rationale:** Improve efficiency
387
  and convenience of finding number of removed elements. **Effect on
388
  original feature:** Code that depends on the return types might have
389
- different semantics in this International Standard. Translation units
390
- compiled against this version of C++ may be incompatible with
391
- translation units compiled against C++17, either failing to link or
392
- having undefined behavior.
393
 
394
  ### [[iterators]]: iterators library <a id="diff.cpp17.iterators">[[diff.cpp17.iterators]]</a>
395
 
396
  **Change:** The specialization of `iterator_traits` for `void*` and for
397
  function pointer types no longer contains any nested typedefs.
@@ -414,11 +431,11 @@ have undefined behavior.
414
  ### [[input.output]]: input/output library <a id="diff.cpp17.input.output">[[diff.cpp17.input.output]]</a>
415
 
416
  **Change:** Character array extraction only takes array types.
417
  **Rationale:** Increase safety via preventing buffer overflow at compile
418
  time. **Effect on original feature:** Valid C++17 code may fail to
419
- compile in this International Standard:
420
 
421
  ``` cpp
422
  auto p = new char[100];
423
  char q[100];
424
  std::cin >> std::setw(20) >> p; // ill-formed; previously well-formed
@@ -427,11 +444,12 @@ std::cin >> std::setw(20) >> q; // OK
427
 
428
  **Change:** Overload resolution for ostream inserters used with UTF-8
429
  literals. **Rationale:** Required for new features. **Effect on original
430
  feature:** Valid C++17 code that passes UTF-8 literals to
431
  `basic_ostream<char, ...>::operator<<` or
432
- `basic_ostream<wchar_t, ...>::operator<<` is now ill-formed.
 
433
 
434
  ``` cpp
435
  std::cout << u8"text"; // previously called operator<<(const char*) and printed a string;
436
  // now ill-formed
437
  std::cout << u8'X'; // previously called operator<<(char) and printed a character;
@@ -442,11 +460,12 @@ std::cout << u8'X'; // previously called operator<<(char) and printe
442
  `wchar_t`, `char16_t`, or `char32_t` types. **Rationale:** Removal of
443
  surprising behavior. **Effect on original feature:** Valid C++17 code
444
  that passes `wchar_t`, `char16_t`, or `char32_t` characters or strings
445
  to `basic_ostream<char, ...>::operator<<` or that passes `char16_t` or
446
  `char32_t` characters or strings to
447
- `basic_ostream<wchar_t, ...>::operator<<` is now ill-formed.
 
448
 
449
  ``` cpp
450
  std::cout << u"text"; // previously formatted the string as a pointer value;
451
  // now ill-formed
452
  std::cout << u'X'; // previously formatted the character as an integer value;
@@ -455,11 +474,12 @@ std::cout << u'X'; // previously formatted the character as an inte
455
 
456
  **Change:** Return type of filesystem path format observer member
457
  functions. **Rationale:** Required for new features. **Effect on
458
  original feature:** Valid C++17 code that depends on the `u8string()`
459
  and `generic_u8string()` member functions of `std::filesystem::path`
460
- returning `std::string` is not valid in this International Standard.
 
461
 
462
  ``` cpp
463
  std::filesystem::path p;
464
  std::string s1 = p.u8string(); // ill-formed; previously well-formed
465
  std::string s2 = p.generic_u8string(); // ill-formed; previously well-formed
@@ -469,12 +489,12 @@ std::string s2 = p.generic_u8string(); // ill-formed; previously well-formed
469
 
470
  **Change:** Remove `uncaught_exception`. **Rationale:** The function did
471
  not have a clear specification when multiple exceptions were active, and
472
  has been superseded by `uncaught_exceptions`. **Effect on original
473
  feature:** A valid C++17 program that calls `std::uncaught_exception`
474
- may fail to compile. It might be revised to use
475
- `std::uncaught_exceptions` instead, for clear and portable semantics.
476
 
477
  **Change:** Remove support for adaptable function API. **Rationale:**
478
  The deprecated support relied on a limited convention that could not be
479
  extended to support the general case or new language features. It has
480
  been superseded by direct language support with `decltype`, and by the
@@ -493,14 +513,14 @@ C++17 program that directly makes use of the `pointer`, `const_pointer`,
493
  `reference`, `const_reference`, `rebind`, `address`, `construct`,
494
  `destroy`, or `max_size` members of `std::allocator`, or that directly
495
  calls `allocate` with an additional hint argument, may fail to compile.
496
 
497
  **Change:** Remove `raw_storage_iterator`. **Rationale:** The iterator
498
- encouraged use of algorithms that might throw exceptions, but did not
499
- return the number of elements successfully constructed that might need
500
- to be destroyed in order to avoid leaks. **Effect on original feature:**
501
- A valid C++17 program that uses this iterator class may fail to compile.
502
 
503
  **Change:** Remove temporary buffers API. **Rationale:** The temporary
504
  buffer facility was intended to provide an efficient optimization for
505
  small memory requests, but there is little evidence this was achieved in
506
  practice, while requiring the user to provide their own exception-safe
@@ -510,19 +530,19 @@ original feature:** A valid C++17 program that calls
510
 
511
  **Change:** Remove `shared_ptr::unique`. **Rationale:** The result of a
512
  call to this member function is not reliable in the presence of multiple
513
  threads and weak pointers. The member function `use_count` is similarly
514
  unreliable, but has a clearer contract in such cases, and remains
515
- available for well defined use in single-threaded cases. **Effect on
516
  original feature:** A valid C++17 program that calls `unique` on a
517
  `shared_ptr` object may fail to compile.
518
 
519
  **Change:** Remove deprecated type traits. **Rationale:** The traits had
520
  unreliable or awkward interfaces. The `is_literal_type` trait provided
521
  no way to detect which subset of constructors and member functions of a
522
  type were declared `constexpr`. The `result_of` trait had a surprising
523
- syntax that could not report the result of a regular function type. It
524
- has been superseded by the `invoke_result` trait. **Effect on original
525
- feature:** A valid C++17 program that relies on the `is_literal_type` or
526
  `result_of` type traits, on the `is_literal_type_v` variable template,
527
  or on the `result_of_t` alias template may fail to compile.
528
 
 
1
  ## C++ and ISO C++17 <a id="diff.cpp17">[[diff.cpp17]]</a>
2
 
3
+ ### General <a id="diff.cpp17.general">[[diff.cpp17.general]]</a>
4
+
5
+ Subclause [[diff.cpp17]] lists the differences between C++ and ISO C++17
6
+ (ISO/IEC 14882:2017, *Programming Languages — C++*), by the chapters of
7
+ this document.
8
 
9
  ### [[lex]]: lexical conventions <a id="diff.cpp17.lex">[[diff.cpp17.lex]]</a>
10
 
11
  **Change:** New identifiers with special meaning. **Rationale:**
12
  Required for new features. **Effect on original feature:** Logical lines
13
  beginning with `module` or `import` may be interpreted differently in
14
+ this revision of C++. For example:
 
 
15
 
16
  ``` cpp
17
  class module {};
18
  module m1; // was variable declaration; now module-declaration
19
  module *m2; // variable declaration
20
 
21
  class import {};
22
+ import j1; // was variable declaration; now module-import-declaration
23
  ::import j2; // variable declaration
24
  ```
25
 
 
 
26
  **Change:** *header-name* tokens are formed in more contexts.
27
  **Rationale:** Required for new features. **Effect on original
28
  feature:** When the identifier `import` is followed by a `<` character,
29
+ a *header-name* token may be formed. For example:
 
 
30
 
31
  ``` cpp
32
  template<typename> class import {};
33
  import<int> f(); // ill-formed; previously well-formed
34
  ::import<int> g(); // OK
35
  ```
36
 
 
 
37
  **Change:** New keywords. **Rationale:** Required for new features.
38
 
39
  - The `char8_t` keyword is added to differentiate the types of ordinary
40
  and UTF-8 literals [[lex.string]].
41
  - The `concept` keyword is added to enable the definition of concepts
 
50
  *requires-clause* [[temp.pre]] or a *requires-expression*
51
  [[expr.prim.req]].
52
 
53
  Valid C++17 code using `char8_t`, `concept`, `consteval`, `constinit`,
54
  `co_await`, `co_yield`, `co_return`, or `requires` as an identifier is
55
+ not valid in this revision of C++.
56
 
57
  **Change:** New operator `<=>`. **Rationale:** Necessary for new
58
  functionality. **Effect on original feature:** Valid C++17 code that
59
  contains a `<=` token immediately followed by a `>` token may be
60
+ ill-formed or have different semantics in this revision of C++. For
61
+ example:
62
 
63
  ``` cpp
64
  namespace N {
65
  struct X {};
66
  bool operator<=(X, X);
 
73
  Required for new features. The changed types enable function
74
  overloading, template specialization, and type deduction to distinguish
75
  ordinary and UTF-8 string and character literals. **Effect on original
76
  feature:** Valid C++17 code that depends on UTF-8 string literals having
77
  type “array of `const char`” and UTF-8 character literals having type
78
+ “`char`” is not valid in this revision of C++. For example:
79
 
80
  ``` cpp
81
  const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*
82
  const char *ps = u8s; // ill-formed; previously well-formed
83
 
 
99
  ### [[basic]]: basics <a id="diff.cpp17.basic">[[diff.cpp17.basic]]</a>
100
 
101
  **Change:** A pseudo-destructor call ends the lifetime of the object to
102
  which it is applied. **Rationale:** Increase consistency of the language
103
  model. **Effect on original feature:** Valid ISO C++17 code may be
104
+ ill-formed or have undefined behavior in this revision of C++. For
105
+ example:
 
106
 
107
  ``` cpp
108
  int f() {
109
  int a = 123;
110
  using T = int;
111
  a.~T();
112
  return a; // undefined behavior; previously returned 123
113
  }
114
  ```
115
 
 
 
116
  **Change:** Except for the initial release operation, a release sequence
117
  consists solely of atomic read-modify-write operations. **Rationale:**
118
  Removal of rarely used and confusing feature. **Effect on original
119
  feature:** If a `memory_order_release` atomic store is followed by a
120
  `memory_order_relaxed` store to the same variable by the same thread,
 
134
  ### [[dcl.dcl]]: declarations <a id="diff.cpp17.dcl.dcl">[[diff.cpp17.dcl.dcl]]</a>
135
 
136
  **Change:** Unnamed classes with a typedef name for linkage purposes can
137
  contain only C-compatible constructs. **Rationale:** Necessary for
138
  implementability. **Effect on original feature:** Valid C++17 code may
139
+ be ill-formed in this revision of C++. For example:
140
 
141
  ``` cpp
142
  typedef struct {
143
  void f() {} // ill-formed; previously well-formed
144
  } S;
145
  ```
146
 
147
  **Change:** A function cannot have different default arguments in
148
  different translation units. **Rationale:** Required for modules
149
  support. **Effect on original feature:** Valid C++17 code may be
150
+ ill-formed in this revision of C++, with no diagnostic required. For
151
+ example:
152
 
153
  ``` cpp
154
  // Translation unit 1
155
  int f(int a = 42);
156
  int g() { return f(); }
 
164
  **Change:** A class that has user-declared constructors is never an
165
  aggregate. **Rationale:** Remove potentially error-prone aggregate
166
  initialization which may apply notwithstanding the declared constructors
167
  of a class. **Effect on original feature:** Valid C++17 code that
168
  aggregate-initializes a type with a user-declared constructor may be
169
+ ill-formed or have different semantics in this revision of C++. For
170
+ example:
171
 
172
  ``` cpp
173
  struct A { // not an aggregate; previously an aggregate
174
  A() = delete;
175
  };
 
203
  ```
204
 
205
  **Change:** Boolean conversion from a pointer or pointer-to-member type
206
  is now a narrowing conversion. **Rationale:** Catches bugs. **Effect on
207
  original feature:** Valid C++17 code may fail to compile in this
208
+ revision of C++. For example:
209
 
210
  ``` cpp
211
  bool y[] = { "bc" }; // ill-formed; previously well-formed
212
  ```
213
 
 
217
  immediately after an `explicit` *decl-specifier* in a constructor
218
  declaration. The *conversion-function-id* can no longer be used
219
  parenthesized immediately after an `explicit` *decl-specifier* in a
220
  conversion function declaration. **Rationale:** Necessary for new
221
  functionality. **Effect on original feature:** Valid C++17 code may fail
222
+ to compile in this revision of C++. For example:
223
 
224
  ``` cpp
225
  struct S {
226
  explicit (S)(const S&); // ill-formed; previously well-formed
227
  explicit (operator int)(); // ill-formed; previously well-formed
 
230
  ```
231
 
232
  **Change:** A *simple-template-id* is no longer valid as the
233
  *declarator-id* of a constructor or destructor. **Rationale:** Remove
234
  potentially error-prone option for redundancy. **Effect on original
235
+ feature:** Valid C++17 code may fail to compile in this revision of C++.
236
+ For example:
237
 
238
  ``` cpp
239
  template<class T>
240
  struct A {
241
  A<T>(); // error: simple-template-id not allowed for constructor
 
248
  a constructor taking an rvalue reference to a type different from that
249
  of the returned expression. Function and catch-clause parameters can be
250
  thrown using move constructors. **Rationale:** Side effect of making it
251
  easier to write more efficient code that takes advantage of moves.
252
  **Effect on original feature:** Valid C++17 code may fail to compile or
253
+ have different semantics in this revision of C++. For example:
254
 
255
  ``` cpp
256
  struct base {
257
  base();
258
  base(base const &);
 
287
  ### [[over]]: overloading <a id="diff.cpp17.over">[[diff.cpp17.over]]</a>
288
 
289
  **Change:** Equality and inequality expressions can now find reversed
290
  and rewritten candidates. **Rationale:** Improve consistency of equality
291
  with three-way comparison and make it easier to write the full
292
+ complement of equality operations. **Effect on original feature:** For
293
+ certain pairs of types where one is convertible to the other, equality
294
+ or inequality expressions between an object of one type and an object of
295
+ the other type invoke a different operator. Also, for certain types,
296
+ equality or inequality expressions between two objects of that type
297
+ become ambiguous. For example:
298
 
299
  ``` cpp
300
  struct A {
301
  operator int() const;
302
  };
 
310
  (10 == x) + // calls #1, previously selected #2
311
  (10 != x); // calls #1, previously selected #3
312
  }
313
  ```
314
 
315
+ **Change:** Overload resolution may change for equality operators
316
+ [[expr.eq]]. **Rationale:** Support calling `operator==` with reversed
317
+ order of arguments. **Effect on original feature:** Valid C++17 code
318
+ that uses equality operators with conversion functions may be ill-formed
319
+ or have different semantics in this revision of C++. For example:
320
+
321
+ ``` cpp
322
+ struct A {
323
+ operator int() const { return 10; }
324
+ };
325
+
326
+ bool operator==(A, int); // #1
327
+ // #2 is built-in candidate: bool operator==(int, int);
328
+ bool b = 10 == A(); // calls #1 with reversed order of arguments; previously selected #2
329
+
330
+ struct B {
331
+ bool operator==(const B&); // member function with no cv-qualifier
332
+ };
333
+ B b1;
334
+ bool eq = (b1 == b1); // ambiguous; previously well-formed
335
+ ```
336
+
337
  ### [[temp]]: templates <a id="diff.cpp17.temp">[[diff.cpp17.temp]]</a>
338
 
339
  **Change:** An *unqualified-id* that is followed by a `<` and for which
340
  name lookup finds nothing or finds a function will be treated as a
341
  *template-name* in order to potentially cause argument dependent lookup
342
  to be performed. **Rationale:** It was problematic to call a function
343
  template with an explicit template argument list via argument dependent
344
  lookup because of the need to have a template with the same name visible
345
  via normal lookup. **Effect on original feature:** Previously valid code
346
  that uses a function name as the left operand of a `<` operator would
347
+ become ill-formed. For example:
348
 
349
  ``` cpp
350
  struct A {};
351
  bool operator<(void (*fp)(), A);
352
  void f() {}
353
  int main() {
354
  A a;
355
  f < a; // ill-formed; previously well-formed
356
+ (f) < a; // still well-formed
357
  }
358
  ```
359
 
360
  ### [[except]]: exception handling <a id="diff.cpp17.except">[[diff.cpp17.except]]</a>
361
 
362
  **Change:** Remove `throw()` exception specification. **Rationale:**
363
  Removal of obsolete feature that has been replaced by `noexcept`.
364
  **Effect on original feature:** A valid C++17 function declaration,
365
  member function declaration, function pointer declaration, or function
366
  reference declaration that uses `throw()` for its exception
367
+ specification will be rejected as ill-formed in this revision of C++. It
368
+ should simply be replaced with `noexcept` for no change of meaning since
369
+ C++17.
370
 
371
  [*Note 1*: There is no way to write a function declaration that is
372
+ non-throwing in this revision of C++ and is also non-throwing in C++03
373
+ except by using the preprocessor to generate a different token sequence
374
+ in each case. — *end note*]
375
 
376
  ### [[library]]: library introduction <a id="diff.cpp17.library">[[diff.cpp17.library]]</a>
377
 
378
  **Change:** New headers. **Rationale:** New functionality. **Effect on
379
  original feature:** The following C++ headers are new: `<barrier>`,
380
  `<bit>`, `<charconv>`, `<compare>`, `<concepts>`, `<coroutine>`,
381
  `<format>`, `<latch>`, `<numbers>`, `<ranges>`, `<semaphore>`,
382
  `<source_location>`, `<span>`, `<stop_token>`, `<syncstream>`, and
383
  `<version>`. Valid C++17 code that `#include`s headers with these names
384
+ may be invalid in this revision of C++.
385
 
386
  **Change:** Remove vacuous C++ header files. **Rationale:** The empty
387
  headers implied a false requirement to achieve C compatibility with the
388
  C++ headers. **Effect on original feature:** A valid C++17 program that
389
  `#include`s any of the following headers may fail to compile:
 
401
 
402
  **Change:** Return types of `remove`, `remove_if`, and `unique` changed
403
  from `void` to `container::size_type`. **Rationale:** Improve efficiency
404
  and convenience of finding number of removed elements. **Effect on
405
  original feature:** Code that depends on the return types might have
406
+ different semantics in this revision of C++. Translation units compiled
407
+ against this version of C++ may be incompatible with translation units
408
+ compiled against C++17, either failing to link or having undefined
409
+ behavior.
410
 
411
  ### [[iterators]]: iterators library <a id="diff.cpp17.iterators">[[diff.cpp17.iterators]]</a>
412
 
413
  **Change:** The specialization of `iterator_traits` for `void*` and for
414
  function pointer types no longer contains any nested typedefs.
 
431
  ### [[input.output]]: input/output library <a id="diff.cpp17.input.output">[[diff.cpp17.input.output]]</a>
432
 
433
  **Change:** Character array extraction only takes array types.
434
  **Rationale:** Increase safety via preventing buffer overflow at compile
435
  time. **Effect on original feature:** Valid C++17 code may fail to
436
+ compile in this revision of C++. For example:
437
 
438
  ``` cpp
439
  auto p = new char[100];
440
  char q[100];
441
  std::cin >> std::setw(20) >> p; // ill-formed; previously well-formed
 
444
 
445
  **Change:** Overload resolution for ostream inserters used with UTF-8
446
  literals. **Rationale:** Required for new features. **Effect on original
447
  feature:** Valid C++17 code that passes UTF-8 literals to
448
  `basic_ostream<char, ...>::operator<<` or
449
+ `basic_ostream<wchar_t, ...>::operator<<` is now ill-formed. For
450
+ example:
451
 
452
  ``` cpp
453
  std::cout << u8"text"; // previously called operator<<(const char*) and printed a string;
454
  // now ill-formed
455
  std::cout << u8'X'; // previously called operator<<(char) and printed a character;
 
460
  `wchar_t`, `char16_t`, or `char32_t` types. **Rationale:** Removal of
461
  surprising behavior. **Effect on original feature:** Valid C++17 code
462
  that passes `wchar_t`, `char16_t`, or `char32_t` characters or strings
463
  to `basic_ostream<char, ...>::operator<<` or that passes `char16_t` or
464
  `char32_t` characters or strings to
465
+ `basic_ostream<wchar_t, ...>::operator<<` is now ill-formed. For
466
+ example:
467
 
468
  ``` cpp
469
  std::cout << u"text"; // previously formatted the string as a pointer value;
470
  // now ill-formed
471
  std::cout << u'X'; // previously formatted the character as an integer value;
 
474
 
475
  **Change:** Return type of filesystem path format observer member
476
  functions. **Rationale:** Required for new features. **Effect on
477
  original feature:** Valid C++17 code that depends on the `u8string()`
478
  and `generic_u8string()` member functions of `std::filesystem::path`
479
+ returning `std::string` is not valid in this revision of C++. For
480
+ example:
481
 
482
  ``` cpp
483
  std::filesystem::path p;
484
  std::string s1 = p.u8string(); // ill-formed; previously well-formed
485
  std::string s2 = p.generic_u8string(); // ill-formed; previously well-formed
 
489
 
490
  **Change:** Remove `uncaught_exception`. **Rationale:** The function did
491
  not have a clear specification when multiple exceptions were active, and
492
  has been superseded by `uncaught_exceptions`. **Effect on original
493
  feature:** A valid C++17 program that calls `std::uncaught_exception`
494
+ may fail to compile. It can be revised to use `std::uncaught_exceptions`
495
+ instead, for clear and portable semantics.
496
 
497
  **Change:** Remove support for adaptable function API. **Rationale:**
498
  The deprecated support relied on a limited convention that could not be
499
  extended to support the general case or new language features. It has
500
  been superseded by direct language support with `decltype`, and by the
 
513
  `reference`, `const_reference`, `rebind`, `address`, `construct`,
514
  `destroy`, or `max_size` members of `std::allocator`, or that directly
515
  calls `allocate` with an additional hint argument, may fail to compile.
516
 
517
  **Change:** Remove `raw_storage_iterator`. **Rationale:** The iterator
518
+ encouraged use of potentially-throwing algorithms, but did not return
519
+ the number of elements successfully constructed, as would be necessary
520
+ to destroy them. **Effect on original feature:** A valid C++17 program
521
+ that uses this iterator class may fail to compile.
522
 
523
  **Change:** Remove temporary buffers API. **Rationale:** The temporary
524
  buffer facility was intended to provide an efficient optimization for
525
  small memory requests, but there is little evidence this was achieved in
526
  practice, while requiring the user to provide their own exception-safe
 
530
 
531
  **Change:** Remove `shared_ptr::unique`. **Rationale:** The result of a
532
  call to this member function is not reliable in the presence of multiple
533
  threads and weak pointers. The member function `use_count` is similarly
534
  unreliable, but has a clearer contract in such cases, and remains
535
+ available for well-defined use in single-threaded cases. **Effect on
536
  original feature:** A valid C++17 program that calls `unique` on a
537
  `shared_ptr` object may fail to compile.
538
 
539
  **Change:** Remove deprecated type traits. **Rationale:** The traits had
540
  unreliable or awkward interfaces. The `is_literal_type` trait provided
541
  no way to detect which subset of constructors and member functions of a
542
  type were declared `constexpr`. The `result_of` trait had a surprising
543
+ syntax that did not directly support function types. It has been
544
+ superseded by the `invoke_result` trait. **Effect on original feature:**
545
+ A valid C++17 program that relies on the `is_literal_type` or
546
  `result_of` type traits, on the `is_literal_type_v` variable template,
547
  or on the `result_of_t` alias template may fail to compile.
548