From Jason Turner

[diff.cpp03]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpd5qrsume/{from.md → to.md} +217 -268
tmp/tmpd5qrsume/{from.md → to.md} RENAMED
@@ -1,31 +1,29 @@
1
  ## C++ and ISO C++03 <a id="diff.cpp03">[[diff.cpp03]]</a>
2
 
3
  This subclause lists the differences between C++ and ISO C++03 (ISO/IEC
4
- 14882:2003, *Programming Languages — C++*), by the chapters of this
5
- document.
6
 
7
- ### Clause [[lex]]: lexical conventions <a id="diff.cpp03.lex">[[diff.cpp03.lex]]</a>
8
 
9
- [[lex.pptoken]] **Change:** New kinds of string literals. **Rationale:**
10
- Required for new features. **Effect on original feature:** Valid
11
- C++03code may fail to compile or produce different results in this
12
- International Standard. Specifically, macros named `R`, `u8`, `u8R`,
13
- `u`, `uR`, `U`, `UR`, or `LR` will not be expanded when adjacent to a
14
- string literal but will be interpreted as part of the string literal.
15
- For example,
16
 
17
  ``` cpp
18
  #define u8 "abc"
19
  const char* s = u8"def"; // Previously "abcdef", now "def"
20
  ```
21
 
22
- [[lex.pptoken]] **Change:** User-defined literal string support.
23
- **Rationale:** Required for new features. **Effect on original
24
- feature:** Valid C++03code may fail to compile or produce different
25
- results in this International Standard, as the following example
26
- illustrates.
27
 
28
  ``` cpp
29
  #define _x "there"
30
  "hello"_x // #1
31
  ```
@@ -33,297 +31,252 @@ illustrates.
33
  Previously, \#1 would have consisted of two separate preprocessing
34
  tokens and the macro `_x` would have been expanded. In this
35
  International Standard, \#1 consists of a single preprocessing token, so
36
  the macro is not expanded.
37
 
38
- [[lex.key]] **Change:** New keywords. **Rationale:** Required for new
39
- features. **Effect on original feature:** Added to Table 
40
- [[tab:keywords]], the following identifiers are new keywords: `alignas`,
41
- `alignof`, `char16_t`, `char32_t`, `constexpr`, `decltype`, `noexcept`,
42
- `nullptr`, `static_assert`, and `thread_local`. Valid C++03code using
43
- these identifiers is invalid in this International Standard.
44
 
45
- [[lex.icon]] **Change:** Type of integer literals. **Rationale:** C99
46
- compatibility. **Effect on original feature:** Certain integer literals
47
- larger than can be represented by `long` could change from an unsigned
48
- integer type to `signed long long`.
49
 
50
- ### Clause  [[conv]]: standard conversions <a id="diff.cpp03.conv">[[diff.cpp03.conv]]</a>
51
 
52
- [[conv.ptr]] **Change:** Only literals are integer null pointer
53
- constants. **Rationale:** Removing surprising interactions with
54
- templates and constant expressions. **Effect on original feature:**
55
- Valid C++03code may fail to compile or produce different results in this
56
- International Standard, as the following example illustrates:
57
 
58
  ``` cpp
59
  void f(void *); // #1
60
  void f(...); // #2
61
  template<int N> void g() {
62
  f(0*N); // calls #2; used to call #1
63
  }
64
  ```
65
 
66
- ### Clause [[expr]]: expressions <a id="diff.cpp03.expr">[[diff.cpp03.expr]]</a>
67
-
68
- [[expr.mul]] **Change:** Specify rounding for results of integer `/` and
69
- `%`. **Rationale:** Increase portability, C99 compatibility. **Effect on
70
  original feature:** Valid C++03 code that uses integer division rounds
71
  the result toward 0 or toward negative infinity, whereas this
72
  International Standard always rounds the result toward 0.
73
 
74
- [[expr.log.and]] **Change:** `&&` is valid in a *type-name*.
75
- **Rationale:** Required for new features. **Effect on original
76
- feature:** Valid C++03code may fail to compile or produce different
77
- results in this International Standard, as the following example
78
- illustrates:
79
 
80
  ``` cpp
81
  bool b1 = new int && false; // previously false, now ill-formed
82
  struct S { operator int(); };
83
  bool b2 = &S::operator int && false; // previously false, now ill-formed
84
  ```
85
 
86
- ### Clause [[dcl.dcl]]: declarations <a id="diff.cpp03.dcl.dcl">[[diff.cpp03.dcl.dcl]]</a>
87
 
88
- [[dcl.spec]] **Change:** Remove `auto` as a storage class specifier.
89
- **Rationale:** New feature. **Effect on original feature:** Valid
90
- C++03code that uses the keyword `auto` as a storage class specifier may
91
- be invalid in this International Standard. In this International
92
- Standard, `auto` indicates that the type of a variable is to be deduced
93
- from its initializer expression.
94
 
95
- ### Clause [[dcl.decl]]: declarators <a id="diff.cpp03.dcl.decl">[[diff.cpp03.dcl.decl]]</a>
96
-
97
- [[dcl.init.list]] **Change:** Narrowing restrictions in aggregate
98
- initializers. **Rationale:** Catches bugs. **Effect on original
99
- feature:** Valid C++03code may fail to compile in this International
100
- Standard. For example, the following code is valid in C++03but invalid
101
- in this International Standard because `double` to `int` is a narrowing
102
- conversion:
103
 
104
  ``` cpp
105
  int x[] = { 2.0 };
106
  ```
107
 
108
- ### Clause [[special]]: special member functions <a id="diff.cpp03.special">[[diff.cpp03.special]]</a>
109
 
110
- [[class.ctor]], [[class.dtor]], [[class.copy]] **Change:**
111
- Implicitly-declared special member functions are defined as deleted when
112
- the implicit definition would have been ill-formed. **Rationale:**
113
- Improves template argument deduction failure. **Effect on original
114
- feature:** A valid C++03program that uses one of these special member
115
- functions in a context where the definition is not required (e.g., in an
116
- expression that is not potentially evaluated) becomes ill-formed.
117
 
118
- [[class.dtor]] (destructors) **Change:** User-declared destructors have
119
- an implicit exception specification. **Rationale:** Clarification of
120
- destructor requirements. **Effect on original feature:** Valid C++03code
121
- may execute differently in this International Standard. In particular,
122
- destructors that throw exceptions will call `std::terminate` (without
123
- calling `std::unexpected`) if their exception specification is
124
- non-throwing.
125
 
126
- ### Clause [[temp]]: templates <a id="diff.cpp03.temp">[[diff.cpp03.temp]]</a>
127
 
128
- [[temp.param]] **Change:** Remove `export`. **Rationale:** No
129
- implementation consensus. **Effect on original feature:** A valid
130
- C++03declaration containing `export` is ill-formed in this International
131
- Standard.
132
 
133
- [[temp.arg]] **Change:** Remove whitespace requirement for nested
134
- closing template right angle brackets. **Rationale:** Considered a
135
- persistent but minor annoyance. Template aliases representing non-class
136
- types would exacerbate whitespace issues. **Effect on original
137
- feature:** Change to semantics of well-defined expression. A valid
138
- C++03expression containing a right angle bracket (“`>`”) followed
139
- immediately by another right angle bracket may now be treated as closing
140
- two templates. For example, the following code is valid in C++03because
141
- “`>>`” is a right-shift operator, but invalid in this International
142
- Standard because “`>>`” closes two templates.
143
 
144
  ``` cpp
145
  template <class T> struct X { };
146
  template <int N> struct Y { };
147
  X< Y< 1 >> 2 > > x;
148
  ```
149
 
150
- [[temp.dep.candidate]] **Change:** Allow dependent calls of functions
151
- with internal linkage. **Rationale:** Overly constrained, simplify
152
- overload resolution rules. **Effect on original feature:** A valid
153
- C++03program could get a different result than this International
154
- Standard.
155
-
156
- ### Clause [[library]]: library introduction <a id="diff.cpp03.library">[[diff.cpp03.library]]</a>
157
-
158
- [[library]] – [[thread]] **Change:** New reserved identifiers.
159
- **Rationale:** Required by new features. **Effect on original feature:**
160
- Valid C++03code that uses any identifiers added to the C++standard
161
- library by this International Standard may fail to compile or produce
162
- different results in this International Standard. A comprehensive list
163
- of identifiers used by the C++standard library can be found in the Index
164
- of Library Names in this International Standard.
165
-
166
- [[headers]] **Change:** New headers. **Rationale:** New functionality.
167
- **Effect on original feature:** The following C++headers are new:
168
- `<array>`, `<atomic>`, `<chrono>`, `<codecvt>`, `<condition_variable>`,
169
- `<forward_list>`, `<future>`, `<initializer_list>`, `<mutex>`,
170
- `<random>`, `<ratio>`, `<regex>`, `<scoped_allocator>`,
171
- `<system_error>`, `<thread>`, `<tuple>`, `<typeindex>`,
172
- `<type_traits>`,
173
- `<unordered_map>`, and `<unordered_set>`. In addition the following C
174
- compatibility headers are new: `<ccomplex>`, `<cfenv>`, `<cinttypes>`,
175
- `<cstdalign>`, `<cstdbool>`, `<cstdint>`, `<ctgmath>`, and `<cuchar>`.
176
- Valid C++03code that `#include`s headers with these names may be invalid
177
- in this International Standard.
178
-
179
- [[swappable.requirements]] **Effect on original feature:** Function
180
- `swap` moved to a different header **Rationale:** Remove dependency on
181
- `<algorithm>` for `swap`. **Effect on original feature:** Valid
182
- C++03code that has been compiled expecting swap to be in `<algorithm>`
183
- may have to instead include `<utility>`.
184
-
185
- [[namespace.posix]] **Change:** New reserved namespace. **Rationale:**
186
- New functionality. **Effect on original feature:** The global namespace
187
- `posix` is now reserved for standardization. Valid C++03code that uses a
188
- top-level namespace `posix` may be invalid in this International
189
- Standard.
190
-
191
- [[res.on.macro.definitions]] **Change:** Additional restrictions on
192
- macro names. **Rationale:** Avoid hard to diagnose or non-portable
193
- constructs. **Effect on original feature:** Names of attribute
194
- identifiers may not be used as macro names. Valid C++ 2003 code that
195
- defines `override`, `final`, `carries_dependency`, or `noreturn` as
196
- macros is invalid in this International Standard.
197
-
198
- ### Clause [[language.support]]: language support library <a id="diff.cpp03.language.support">[[diff.cpp03.language.support]]</a>
199
-
200
- [[new.delete.single]] **Change:** Linking `new` and `delete` operators.
201
- **Rationale:** The two throwing single-object signatures of
202
- `operator new` and `operator delete` are now specified to form the base
203
- functionality for the other operators. This clarifies that replacing
204
- just these two signatures changes others, even if they are not
205
- explicitly changed. **Effect on original feature:** Valid C++03code that
206
- replaces global `new` or `delete` operators may execute differently in
207
- this International Standard. For example, the following program should
208
- write `"custom deallocation"` twice, once for the single-object delete
209
- and once for the array delete.
210
-
211
- ``` cpp
212
- #include <cstdio>
213
- #include <cstdlib>
214
- #include <new>
215
-
216
- void* operator new(std::size_t size) throw(std::bad_alloc) {
217
- return std::malloc(size);
218
- }
219
-
220
- void operator delete(void* ptr) throw() {
221
- std::puts("custom deallocation");
222
- std::free(ptr);
223
- }
224
-
225
- int main() {
226
- int* i = new int;
227
- delete i; // single-object delete
228
- int* a = new int[3];
229
- delete [] a; // array delete
230
- }
231
- ```
232
-
233
- [[new.delete.single]] **Change:** `operator new` may throw exceptions
234
- other than `std::bad_alloc`. **Rationale:** Consistent application of
235
- `noexcept`. **Effect on original feature:** Valid C++03code that assumes
236
- that global `operator new` only throws `std::bad_alloc` may execute
237
- differently in this International Standard.
238
-
239
- ### Clause [[diagnostics]]: diagnostics library <a id="diff.cpp03.diagnostics">[[diff.cpp03.diagnostics]]</a>
240
-
241
- [[errno]] **Change:** Thread-local error numbers. **Rationale:** Support
242
- for new thread facilities. **Effect on original feature:** Valid but
243
  implementation-specific C++03 code that relies on `errno` being the same
244
  across threads may change behavior in this International Standard.
245
 
246
- ### Clause [[utilities]]: general utilities library <a id="diff.cpp03.utilities">[[diff.cpp03.utilities]]</a>
247
 
248
- [[util.dynamic.safety]] **Change:** Minimal support for
249
- garbage-collected regions. **Rationale:** Required by new feature.
250
- **Effect on original feature:** Valid C++03code, compiled without
251
- traceable pointer support, that interacts with newer C++code using
252
- regions declared reachable may have different runtime behavior.
253
 
254
- [[refwrap]], [[arithmetic.operations]], [[comparisons]],
255
- [[logical.operations]], [[bitwise.operations]], [[depr.negators]]
256
  **Change:** Standard function object types no longer derived from
257
  `std::unary_function` or `std::binary_function`. **Rationale:**
258
  Superseded by new feature; `unary_function` and `binary_function` are no
259
  longer defined. **Effect on original feature:** Valid C++03 code that
260
  depends on function object types being derived from `unary_function` or
261
  `binary_function` may fail to compile in this International Standard.
262
 
263
- ### Clause [[strings]]: strings library <a id="diff.cpp03.strings">[[diff.cpp03.strings]]</a>
264
 
265
- [[string.classes]] **Change:** `basic_string` requirements no longer
266
- allow reference-counted strings. **Rationale:** Invalidation is subtly
267
  different with reference-counted strings. This change regularizes
268
  behavior for this International Standard. **Effect on original
269
- feature:** Valid C++03code may execute differently in this International
270
- Standard.
271
 
272
- [[string.require]] **Change:** Loosen `basic_string` invalidation rules.
273
- **Rationale:** Allow small-string optimization. **Effect on original
274
- feature:** Valid C++03code may execute differently in this International
275
- Standard. Some `const` member functions, such as `data` and `c_str`, no
276
- longer invalidate iterators.
277
 
278
- ### Clause [[containers]]: containers library <a id="diff.cpp03.containers">[[diff.cpp03.containers]]</a>
279
 
280
- [[container.requirements]] **Change:** Complexity of `size()` member
281
- functions now constant. **Rationale:** Lack of specification of
282
- complexity of `size()` resulted in divergent implementations with
283
- inconsistent performance characteristics. **Effect on original
284
- feature:** Some container implementations that conform to C++03may not
285
- conform to the specified `size()` requirements in this International
286
- Standard. Adjusting containers such as `std::list` to the stricter
287
- requirements may require incompatible changes.
288
 
289
- [[container.requirements]] **Change:** Requirements change: relaxation.
290
- **Rationale:** Clarification. **Effect on original feature:** Valid
291
- C++03code that attempts to meet the specified container requirements may
292
- now be over-specified. Code that attempted to be portable across
293
- containers may need to be adjusted as follows:
294
 
295
  - not all containers provide `size()`; use `empty()` instead of
296
  `size() == 0`;
297
  - not all containers are empty after construction (`array`);
298
  - not all containers have constant complexity for `swap()` (`array`).
299
 
300
- [[container.requirements]] **Change:** Requirements change: default
301
- constructible. **Rationale:** Clarification of container requirements.
302
- **Effect on original feature:** Valid C++03code that attempts to
303
- explicitly instantiate a container using a user-defined type with no
304
- default constructor may fail to compile.
305
 
306
- [[sequence.reqmts]], [[associative.reqmts]] **Change:** Signature
307
- changes: from `void` return types. **Rationale:** Old signature threw
308
- away useful information that may be expensive to recalculate. **Effect
309
- on original feature:** The following member functions have changed:
310
 
311
  - `erase(iter)` for `set`, `multiset`, `map`, `multimap`
312
  - `erase(begin, end)` for `set`, `multiset`, `map`, `multimap`
313
  - `insert(pos, num, val)` for `vector`, `deque`, `list`, `forward_list`
314
  - `insert(pos, beg, end)` for `vector`, `deque`, `list`, `forward_list`
315
 
316
  Valid C++03 code that relies on these functions returning `void` (e.g.,
317
  code that creates a pointer to member function that points to one of
318
  these functions) will fail to compile with this International Standard.
319
 
320
- [[sequence.reqmts]], [[associative.reqmts]] **Change:** Signature
321
- changes: from `iterator` to `const_iterator` parameters. **Rationale:**
322
- Overspecification. **Effect on original feature:** The signatures of the
323
- following member functions changed from taking an `iterator` to taking a
324
- `const_iterator`:
325
 
326
  - `insert(iter, val)` for `vector`, `deque`, `list`, `set`, `multiset`,
327
  `map`, `multimap`
328
  - `insert(pos, beg, end)` for `vector`, `deque`, `list`, `forward_list`
329
  - `erase(begin, end)` for `set`, `multiset`, `map`, `multimap`
@@ -331,67 +284,63 @@ following member functions changed from taking an `iterator` to taking a
331
  - all forms of `list::merge`
332
 
333
  Valid C++03 code that uses these functions may fail to compile with this
334
  International Standard.
335
 
336
- [[sequence.reqmts]], [[associative.reqmts]] **Change:** Signature
337
- changes: `resize`. **Rationale:** Performance, compatibility with move
338
- semantics. **Effect on original feature:** For `vector`, `deque`, and
339
- `list` the fill value passed to `resize` is now passed by reference
340
- instead of by value, and an additional overload of `resize` has been
341
- added. Valid C++03code that uses this function may fail to compile with
342
- this International Standard.
343
 
344
- ### Clause [[algorithms]]: algorithms library <a id="diff.cpp03.algorithms">[[diff.cpp03.algorithms]]</a>
345
 
346
- [[algorithms.general]] **Change:** Result state of inputs after
347
- application of some algorithms. **Rationale:** Required by new feature.
348
- **Effect on original feature:** A valid C++03program may detect that an
349
- object with a valid but unspecified state has a different valid but
350
- unspecified state with this International Standard. For example,
351
- `std::remove` and `std::remove_if` may leave the tail of the input
352
- sequence with a different set of values than previously.
353
 
354
- ### Clause [[numerics]]: numerics library <a id="diff.cpp03.numerics">[[diff.cpp03.numerics]]</a>
355
 
356
- [[complex.numbers]] **Change:** Specified representation of complex
357
- numbers. **Rationale:** Compatibility with C99. **Effect on original
358
- feature:** Valid C++03code that uses implementation-specific knowledge
359
- about the binary representation of the required template specializations
360
- of `std::complex` may not be compatible with this International
361
- Standard.
362
 
363
- ### Clause [[input.output]]: input/output library <a id="diff.cpp03.input.output">[[diff.cpp03.input.output]]</a>
364
 
365
- [[istream::sentry]], [[ostream::sentry]], [[iostate.flags]] **Change:**
366
- Specify use of `explicit` in existing boolean conversion functions.
367
- **Rationale:** Clarify intentions, avoid workarounds. **Effect on
368
- original feature:** Valid C++03code that relies on implicit boolean
369
- conversions will fail to compile with this International Standard. Such
370
- conversions occur in the following conditions:
371
 
372
  - passing a value to a function that takes an argument of type `bool`;
373
  - using `operator==` to compare to `false` or `true`;
374
  - returning a value from a function with a return type of `bool`;
375
  - initializing members of type `bool` via aggregate initialization;
376
- - initializing a `const bool&` which would bind to a temporary.
377
 
378
- [[ios::failure]] **Change:** Change base class of
379
- `std::ios_base::failure`. **Rationale:** More detailed error messages.
380
- **Effect on original feature:** `std::ios_base::failure` is no longer
381
- derived directly from `std::exception`, but is now derived from
382
- `std::system_error`, which in turn is derived from `std::runtime_error`.
383
- Valid C++03code that assumes that `std::ios_base::failure` is derived
384
- directly from `std::exception` may execute differently in this
385
- International Standard.
386
 
387
- [[ios.base]] **Change:** Flag types in `std::ios_base` are now bitmasks
388
- with values defined as constexpr static members. **Rationale:** Required
389
- for new features. **Effect on original feature:** Valid C++03code that
390
- relies on `std::ios_base` flag types being represented as `std::bitset`
391
- or as an integer type may fail to compile with this International
392
- Standard. For example:
393
 
394
  ``` cpp
395
  #include <iostream>
396
 
397
  int main() {
 
1
  ## C++ and ISO C++03 <a id="diff.cpp03">[[diff.cpp03]]</a>
2
 
3
  This subclause lists the differences between C++ and ISO C++03 (ISO/IEC
4
+ 14882:2003, *Programming Languages — C++*), in addition to those listed
5
+ above, by the chapters of this document.
6
 
7
+ ### [[lex]]: lexical conventions <a id="diff.cpp03.lex">[[diff.cpp03.lex]]</a>
8
 
9
+ **Change:** New kinds of *string-literal*s. **Rationale:** Required for
10
+ new features. **Effect on original feature:** Valid C++03 code may fail
11
+ to compile or produce different results in this International Standard.
12
+ Specifically, macros named `R`, `u8`, `u8R`, `u`, `uR`, `U`, `UR`, or
13
+ `LR` will not be expanded when adjacent to a *string-literal* but will
14
+ be interpreted as part of the *string-literal*. For example:
 
15
 
16
  ``` cpp
17
  #define u8 "abc"
18
  const char* s = u8"def"; // Previously "abcdef", now "def"
19
  ```
20
 
21
+ **Change:** User-defined literal string support. **Rationale:** Required
22
+ for new features. **Effect on original feature:** Valid C++03 code may
23
+ fail to compile or produce different results in this International
24
+ Standard. For example:
 
25
 
26
  ``` cpp
27
  #define _x "there"
28
  "hello"_x // #1
29
  ```
 
31
  Previously, \#1 would have consisted of two separate preprocessing
32
  tokens and the macro `_x` would have been expanded. In this
33
  International Standard, \#1 consists of a single preprocessing token, so
34
  the macro is not expanded.
35
 
36
+ **Change:** New keywords. **Rationale:** Required for new features.
37
+ **Effect on original feature:** Added to [[lex.key]], the following
38
+ identifiers are new keywords: `alignas`, `alignof`, `char16_t`,
39
+ `char32_t`, `constexpr`, `decltype`, `noexcept`, `nullptr`,
40
+ `static_assert`, and `thread_local`. Valid C++03 code using these
41
+ identifiers is invalid in this International Standard.
42
 
43
+ **Change:** Type of integer literals. **Rationale:** C99 compatibility.
44
+ **Effect on original feature:** Certain integer literals larger than can
45
+ be represented by `long` could change from an unsigned integer type to
46
+ `signed long long`.
47
 
48
+ ### [[expr]]: expressions <a id="diff.cpp03.expr">[[diff.cpp03.expr]]</a>
49
 
50
+ **Change:** Only literals are integer null pointer constants.
51
+ **Rationale:** Removing surprising interactions with templates and
52
+ constant expressions. **Effect on original feature:** Valid C++03 code
53
+ may fail to compile or produce different results in this International
54
+ Standard. For example:
55
 
56
  ``` cpp
57
  void f(void *); // #1
58
  void f(...); // #2
59
  template<int N> void g() {
60
  f(0*N); // calls #2; used to call #1
61
  }
62
  ```
63
 
64
+ **Change:** Specify rounding for results of integer `/` and `%`.
65
+ **Rationale:** Increase portability, C99 compatibility. **Effect on
 
 
66
  original feature:** Valid C++03 code that uses integer division rounds
67
  the result toward 0 or toward negative infinity, whereas this
68
  International Standard always rounds the result toward 0.
69
 
70
+ **Change:** `&&` is valid in a *type-name*. **Rationale:** Required for
71
+ new features. **Effect on original feature:** Valid C++03 code may fail
72
+ to compile or produce different results in this International Standard.
73
+ For example:
 
74
 
75
  ``` cpp
76
  bool b1 = new int && false; // previously false, now ill-formed
77
  struct S { operator int(); };
78
  bool b2 = &S::operator int && false; // previously false, now ill-formed
79
  ```
80
 
81
+ ### [[dcl.dcl]]: declarations <a id="diff.cpp03.dcl.dcl">[[diff.cpp03.dcl.dcl]]</a>
82
 
83
+ **Change:** Remove `auto` as a storage class specifier. **Rationale:**
84
+ New feature. **Effect on original feature:** Valid C++03 code that uses
85
+ the keyword `auto` as a storage class specifier may be invalid in this
86
+ International Standard. In this International Standard, `auto` indicates
87
+ that the type of a variable is to be deduced from its initializer
88
+ expression.
89
 
90
+ **Change:** Narrowing restrictions in aggregate initializers.
91
+ **Rationale:** Catches bugs. **Effect on original feature:** Valid C++03
92
+ code may fail to compile in this International Standard. For example,
93
+ the following code is valid in C++03 but invalid in this International
94
+ Standard because `double` to `int` is a narrowing conversion:
 
 
 
95
 
96
  ``` cpp
97
  int x[] = { 2.0 };
98
  ```
99
 
100
+ ### [[class]]: classes <a id="diff.cpp03.class">[[diff.cpp03.class]]</a>
101
 
102
+ **Change:** Implicitly-declared special member functions are defined as
103
+ deleted when the implicit definition would have been ill-formed.
104
+ **Rationale:** Improves template argument deduction failure. **Effect on
105
+ original feature:** A valid C++03 program that uses one of these special
106
+ member functions in a context where the definition is not required
107
+ (e.g., in an expression that is not potentially evaluated) becomes
108
+ ill-formed.
109
 
110
+ **Change:** User-declared destructors have an implicit exception
111
+ specification. **Rationale:** Clarification of destructor requirements.
112
+ **Effect on original feature:** Valid C++03 code may execute differently
113
+ in this International Standard. In particular, destructors that throw
114
+ exceptions will call `std::terminate` (without calling
115
+ `std::unexpected`) if their exception specification is non-throwing.
 
116
 
117
+ ### [[temp]]: templates <a id="diff.cpp03.temp">[[diff.cpp03.temp]]</a>
118
 
119
+ **Change:** Remove `export`. **Rationale:** No implementation consensus.
120
+ **Effect on original feature:** A valid C++03 declaration containing
121
+ `export` is ill-formed in this International Standard.
 
122
 
123
+ **Change:** Remove whitespace requirement for nested closing template
124
+ right angle brackets. **Rationale:** Considered a persistent but minor
125
+ annoyance. Template aliases representing non-class types would
126
+ exacerbate whitespace issues. **Effect on original feature:** Change to
127
+ semantics of well-defined expression. A valid C++03 expression
128
+ containing a right angle bracket (“`>`”) followed immediately by another
129
+ right angle bracket may now be treated as closing two templates. For
130
+ example, the following code is valid in C++03 because “`>>`” is a
131
+ right-shift operator, but invalid in this International Standard because
132
+ “`>>`” closes two templates.
133
 
134
  ``` cpp
135
  template <class T> struct X { };
136
  template <int N> struct Y { };
137
  X< Y< 1 >> 2 > > x;
138
  ```
139
 
140
+ **Change:** Allow dependent calls of functions with internal linkage.
141
+ **Rationale:** Overly constrained, simplify overload resolution rules.
142
+ **Effect on original feature:** A valid C++03 program could get a
143
+ different result than this International Standard.
144
+
145
+ ### [[library]]: library introduction <a id="diff.cpp03.library">[[diff.cpp03.library]]</a>
146
+
147
+ **Affected:** [[library]] – [[thread]] **Change:** New reserved
148
+ identifiers. **Rationale:** Required by new features. **Effect on
149
+ original feature:** Valid C++03 code that uses any identifiers added to
150
+ the C++ standard library by this International Standard may fail to
151
+ compile or produce different results in this International Standard. A
152
+ comprehensive list of identifiers used by the C++ standard library can
153
+ be found in the Index of Library Names in this International Standard.
154
+
155
+ **Change:** New headers. **Rationale:** New functionality. **Effect on
156
+ original feature:** The following C++ headers are new: `<array>`,
157
+ `<atomic>`, `<chrono>`, , `<condition_variable>`, `<forward_list>`,
158
+ `<future>`, `<initializer_list>`, `<mutex>`, `<random>`, `<ratio>`,
159
+ `<regex>`, `<scoped_allocator>`, `<system_error>`, `<thread>`,
160
+ `<tuple>`, `<typeindex>`, `<type_traits>`, `<unordered_map>`, and
161
+ `<unordered_set>`. In addition the following C compatibility headers are
162
+ new: `<cfenv>`, `<cinttypes>`, `<cstdint>`, and `<cuchar>`. Valid C++03
163
+ code that `#include`s headers with these names may be invalid in this
164
+ International Standard.
165
+
166
+ **Effect on original feature:** Function `swap` moved to a different
167
+ header **Rationale:** Remove dependency on `<algorithm>` for `swap`.
168
+ **Effect on original feature:** Valid C++03 code that has been compiled
169
+ expecting swap to be in `<algorithm>` may have to instead include
170
+ `<utility>`.
171
+
172
+ **Change:** New reserved namespace. **Rationale:** New functionality.
173
+ **Effect on original feature:** The global namespace `posix` is now
174
+ reserved for standardization. Valid C++03 code that uses a top-level
175
+ namespace `posix` may be invalid in this International Standard.
176
+
177
+ **Change:** Additional restrictions on macro names. **Rationale:** Avoid
178
+ hard to diagnose or non-portable constructs. **Effect on original
179
+ feature:** Names of attribute identifiers may not be used as macro
180
+ names. Valid C++03 code that defines `override`, `final`,
181
+ `carries_dependency`, or `noreturn` as macros is invalid in this
182
+ International Standard.
183
+
184
+ ### [[support]]: language support library <a id="diff.cpp03.language.support">[[diff.cpp03.language.support]]</a>
185
+
186
+ **Change:** `operator new` may throw exceptions other than
187
+ `std::bad_alloc`. **Rationale:** Consistent application of `noexcept`.
188
+ **Effect on original feature:** Valid C++03 code that assumes that
189
+ global `operator new` only throws `std::bad_alloc` may execute
190
+ differently in this International Standard. Valid C++03 code that
191
+ replaces the global replaceable `operator new` is ill-formed in this
192
+ International Standard, because the exception specification of
193
+ `throw(std::bad_alloc)` was removed.
194
+
195
+ ### [[diagnostics]]: diagnostics library <a id="diff.cpp03.diagnostics">[[diff.cpp03.diagnostics]]</a>
196
+
197
+ **Change:** Thread-local error numbers. **Rationale:** Support for new
198
+ thread facilities. **Effect on original feature:** Valid but
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  implementation-specific C++03 code that relies on `errno` being the same
200
  across threads may change behavior in this International Standard.
201
 
202
+ ### [[utilities]]: general utilities library <a id="diff.cpp03.utilities">[[diff.cpp03.utilities]]</a>
203
 
204
+ **Change:** Minimal support for garbage-collected regions.
205
+ **Rationale:** Required by new feature. **Effect on original feature:**
206
+ Valid C++03 code, compiled without traceable pointer support, that
207
+ interacts with newer C++ code using regions declared reachable may have
208
+ different runtime behavior.
209
 
 
 
210
  **Change:** Standard function object types no longer derived from
211
  `std::unary_function` or `std::binary_function`. **Rationale:**
212
  Superseded by new feature; `unary_function` and `binary_function` are no
213
  longer defined. **Effect on original feature:** Valid C++03 code that
214
  depends on function object types being derived from `unary_function` or
215
  `binary_function` may fail to compile in this International Standard.
216
 
217
+ ### [[strings]]: strings library <a id="diff.cpp03.strings">[[diff.cpp03.strings]]</a>
218
 
219
+ **Change:** `basic_string` requirements no longer allow
220
+ reference-counted strings. **Rationale:** Invalidation is subtly
221
  different with reference-counted strings. This change regularizes
222
  behavior for this International Standard. **Effect on original
223
+ feature:** Valid C++03 code may execute differently in this
224
+ International Standard.
225
 
226
+ **Change:** Loosen `basic_string` invalidation rules. **Rationale:**
227
+ Allow small-string optimization. **Effect on original feature:** Valid
228
+ C++03 code may execute differently in this International Standard. Some
229
+ `const` member functions, such as `data` and `c_str`, no longer
230
+ invalidate iterators.
231
 
232
+ ### [[containers]]: containers library <a id="diff.cpp03.containers">[[diff.cpp03.containers]]</a>
233
 
234
+ **Change:** Complexity of `size()` member functions now constant.
235
+ **Rationale:** Lack of specification of complexity of `size()` resulted
236
+ in divergent implementations with inconsistent performance
237
+ characteristics. **Effect on original feature:** Some container
238
+ implementations that conform to C++03 may not conform to the specified
239
+ `size()` requirements in this International Standard. Adjusting
240
+ containers such as `std::list` to the stricter requirements may require
241
+ incompatible changes.
242
 
243
+ **Change:** Requirements change: relaxation. **Rationale:**
244
+ Clarification. **Effect on original feature:** Valid C++03 code that
245
+ attempts to meet the specified container requirements may now be
246
+ over-specified. Code that attempted to be portable across containers may
247
+ need to be adjusted as follows:
248
 
249
  - not all containers provide `size()`; use `empty()` instead of
250
  `size() == 0`;
251
  - not all containers are empty after construction (`array`);
252
  - not all containers have constant complexity for `swap()` (`array`).
253
 
254
+ **Change:** Requirements change: default constructible. **Rationale:**
255
+ Clarification of container requirements. **Effect on original feature:**
256
+ Valid C++03 code that attempts to explicitly instantiate a container
257
+ using a user-defined type with no default constructor may fail to
258
+ compile.
259
 
260
+ **Change:** Signature changes: from `void` return types. **Rationale:**
261
+ Old signature threw away useful information that may be expensive to
262
+ recalculate. **Effect on original feature:** The following member
263
+ functions have changed:
264
 
265
  - `erase(iter)` for `set`, `multiset`, `map`, `multimap`
266
  - `erase(begin, end)` for `set`, `multiset`, `map`, `multimap`
267
  - `insert(pos, num, val)` for `vector`, `deque`, `list`, `forward_list`
268
  - `insert(pos, beg, end)` for `vector`, `deque`, `list`, `forward_list`
269
 
270
  Valid C++03 code that relies on these functions returning `void` (e.g.,
271
  code that creates a pointer to member function that points to one of
272
  these functions) will fail to compile with this International Standard.
273
 
274
+ **Change:** Signature changes: from `iterator` to `const_iterator`
275
+ parameters. **Rationale:** Overspecification. **Effect on original
276
+ feature:** The signatures of the following member functions changed from
277
+ taking an `iterator` to taking a `const_iterator`:
 
278
 
279
  - `insert(iter, val)` for `vector`, `deque`, `list`, `set`, `multiset`,
280
  `map`, `multimap`
281
  - `insert(pos, beg, end)` for `vector`, `deque`, `list`, `forward_list`
282
  - `erase(begin, end)` for `set`, `multiset`, `map`, `multimap`
 
284
  - all forms of `list::merge`
285
 
286
  Valid C++03 code that uses these functions may fail to compile with this
287
  International Standard.
288
 
289
+ **Change:** Signature changes: `resize`. **Rationale:** Performance,
290
+ compatibility with move semantics. **Effect on original feature:** For
291
+ `vector`, `deque`, and `list` the fill value passed to `resize` is now
292
+ passed by reference instead of by value, and an additional overload of
293
+ `resize` has been added. Valid C++03 code that uses this function may
294
+ fail to compile with this International Standard.
 
295
 
296
+ ### [[algorithms]]: algorithms library <a id="diff.cpp03.algorithms">[[diff.cpp03.algorithms]]</a>
297
 
298
+ **Change:** Result state of inputs after application of some algorithms.
299
+ **Rationale:** Required by new feature. **Effect on original feature:**
300
+ A valid C++03 program may detect that an object with a valid but
301
+ unspecified state has a different valid but unspecified state with this
302
+ International Standard. For example, `std::remove` and `std::remove_if`
303
+ may leave the tail of the input sequence with a different set of values
304
+ than previously.
305
 
306
+ ### [[numerics]]: numerics library <a id="diff.cpp03.numerics">[[diff.cpp03.numerics]]</a>
307
 
308
+ **Change:** Specified representation of complex numbers. **Rationale:**
309
+ Compatibility with C99. **Effect on original feature:** Valid C++03 code
310
+ that uses implementation-specific knowledge about the binary
311
+ representation of the required template specializations of
312
+ `std::complex` may not be compatible with this International Standard.
 
313
 
314
+ ### [[input.output]]: input/output library <a id="diff.cpp03.input.output">[[diff.cpp03.input.output]]</a>
315
 
316
+ **Change:** Specify use of `explicit` in existing boolean conversion
317
+ functions. **Rationale:** Clarify intentions, avoid workarounds.
318
+ **Effect on original feature:** Valid C++03 code that relies on implicit
319
+ boolean conversions will fail to compile with this International
320
+ Standard. Such conversions occur in the following conditions:
 
321
 
322
  - passing a value to a function that takes an argument of type `bool`;
323
  - using `operator==` to compare to `false` or `true`;
324
  - returning a value from a function with a return type of `bool`;
325
  - initializing members of type `bool` via aggregate initialization;
326
+ - initializing a `const bool&` which would bind to a temporary object.
327
 
328
+ **Change:** Change base class of `std::ios_base::failure`.
329
+ **Rationale:** More detailed error messages. **Effect on original
330
+ feature:** `std::ios_base::failure` is no longer derived directly from
331
+ `std::exception`, but is now derived from `std::system_error`, which in
332
+ turn is derived from `std::runtime_error`. Valid C++03 code that assumes
333
+ that `std::ios_base::failure` is derived directly from `std::exception`
334
+ may execute differently in this International Standard.
 
335
 
336
+ **Change:** Flag types in `std::ios_base` are now bitmasks with values
337
+ defined as constexpr static members. **Rationale:** Required for new
338
+ features. **Effect on original feature:** Valid C++03 code that relies
339
+ on `std::ios_base` flag types being represented as `std::bitset` or as
340
+ an integer type may fail to compile with this International Standard.
341
+ For example:
342
 
343
  ``` cpp
344
  #include <iostream>
345
 
346
  int main() {