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