- 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++*),
|
| 5 |
-
document.
|
| 6 |
|
| 7 |
-
###
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
`
|
| 14 |
-
|
| 15 |
-
For example,
|
| 16 |
|
| 17 |
``` cpp
|
| 18 |
#define u8 "abc"
|
| 19 |
const char* s = u8"def"; // Previously "abcdef", now "def"
|
| 20 |
```
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 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 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
`
|
| 42 |
-
`
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
###
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 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 |
-
|
| 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 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 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 |
-
###
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 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 |
-
###
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
non-throwing.
|
| 125 |
|
| 126 |
-
###
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
Standard.
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
template <class T> struct X { };
|
| 146 |
template <int N> struct Y { };
|
| 147 |
X< Y< 1 >> 2 > > x;
|
| 148 |
```
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
`<
|
| 169 |
-
`<
|
| 170 |
-
`<
|
| 171 |
-
`<
|
| 172 |
-
`<
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
`
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
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 |
-
###
|
| 247 |
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 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 |
-
###
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
different with reference-counted strings. This change regularizes
|
| 268 |
behavior for this International Standard. **Effect on original
|
| 269 |
-
feature:** Valid C++
|
| 270 |
-
Standard.
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
|
| 278 |
-
###
|
| 279 |
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 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 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 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 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 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 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
this International Standard.
|
| 343 |
|
| 344 |
-
###
|
| 345 |
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
|
| 354 |
-
###
|
| 355 |
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
Standard.
|
| 362 |
|
| 363 |
-
###
|
| 364 |
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
**
|
| 368 |
-
|
| 369 |
-
|
| 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 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
International Standard.
|
| 386 |
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 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() {
|