tmp/tmpwe0oowo1/{from.md → to.md}
RENAMED
|
@@ -1,58 +1,58 @@
|
|
| 1 |
## C++ and ISO C++11 <a id="diff.cpp11">[[diff.cpp11]]</a>
|
| 2 |
|
| 3 |
This subclause lists the differences between C++ and ISO C++11 (ISO/IEC
|
| 4 |
-
14882:2011, *Programming Languages — C++*),
|
| 5 |
-
document.
|
| 6 |
|
| 7 |
-
###
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
#define M(x, ...) __VA_ARGS__
|
| 20 |
int x[2] = { M(1'2,3'4, 5) };
|
| 21 |
-
// int x[2] = { 5 \ \ \ \ \ } --- C++11
|
| 22 |
// int x[2] = { 3'4, 5 } --- this International Standard
|
| 23 |
```
|
| 24 |
|
| 25 |
-
###
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
void* operator new(std::size_t, std::size_t);
|
| 34 |
void operator delete(void*, std::size_t) noexcept;
|
| 35 |
```
|
| 36 |
|
| 37 |
In this International Standard, however, the declaration of
|
| 38 |
`operator delete` might match a predefined usual (non-placement)
|
| 39 |
-
`operator delete`
|
| 40 |
ill-formed, as it was for class member allocation functions and
|
| 41 |
-
deallocation functions
|
| 42 |
|
| 43 |
-
###
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
[[conv.
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
struct S {
|
| 57 |
int x = 1;
|
| 58 |
void mf() { x = 2; }
|
|
@@ -72,57 +72,55 @@ sizeof(true ? "" : throw 0)
|
|
| 72 |
```
|
| 73 |
|
| 74 |
In C++11, the expression yields `sizeof(const char*)`. In this
|
| 75 |
International Standard, it yields `sizeof(const char[1])`.
|
| 76 |
|
| 77 |
-
###
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
|
| 87 |
``` cpp
|
| 88 |
struct S {
|
| 89 |
constexpr const int &f();
|
| 90 |
int &f();
|
| 91 |
};
|
| 92 |
```
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
original feature:** Valid C++11code may fail to compile or may change
|
| 100 |
-
meaning in this International Standard.
|
| 101 |
|
| 102 |
``` cpp
|
| 103 |
-
struct S {
|
| 104 |
int m = 1;
|
| 105 |
};
|
| 106 |
struct X {
|
| 107 |
operator int();
|
| 108 |
operator S();
|
| 109 |
};
|
| 110 |
X a{};
|
| 111 |
-
S b{a};
|
| 112 |
// performs aggregate initialization in this International Standard
|
| 113 |
```
|
| 114 |
|
| 115 |
-
###
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
in this International Standard.
|
| 121 |
-
|
| 122 |
-
### Clause [[input.output]]: input/output library <a id="diff.cpp11.input.output">[[diff.cpp11.input.output]]</a>
|
| 123 |
-
|
| 124 |
-
[[c.files]] **Change:** `gets` is not defined. **Rationale:** Use of
|
| 125 |
-
`gets` is considered dangerous. **Effect on original feature:** Valid
|
| 126 |
-
C++11code that uses the `gets` function may fail to compile in this
|
| 127 |
International Standard.
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
## C++ and ISO C++11 <a id="diff.cpp11">[[diff.cpp11]]</a>
|
| 2 |
|
| 3 |
This subclause lists the differences between C++ and ISO C++11 (ISO/IEC
|
| 4 |
+
14882:2011, *Programming Languages — C++*), in addition to those listed
|
| 5 |
+
above, by the chapters of this document.
|
| 6 |
|
| 7 |
+
### [[lex]]: lexical conventions <a id="diff.cpp11.lex">[[diff.cpp11.lex]]</a>
|
| 8 |
|
| 9 |
+
**Change:** *pp-number* can contain one or more single quotes.
|
| 10 |
+
**Rationale:** Necessary to enable single quotes as digit separators.
|
| 11 |
+
**Effect on original feature:** Valid C++11 code may fail to compile or
|
| 12 |
+
may change meaning in this International Standard. For example, the
|
| 13 |
+
following code is valid both in C++11 and in this International
|
| 14 |
+
Standard, but the macro invocation produces different outcomes because
|
| 15 |
+
the single quotes delimit a *character-literal* in C++11, whereas they
|
| 16 |
+
are digit separators in this International Standard:
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
#define M(x, ...) __VA_ARGS__
|
| 20 |
int x[2] = { M(1'2,3'4, 5) };
|
| 21 |
+
// int x[2] = { 5 \ \ \ \ \ } --- C++11{}
|
| 22 |
// int x[2] = { 3'4, 5 } --- this International Standard
|
| 23 |
```
|
| 24 |
|
| 25 |
+
### [[basic]]: basics <a id="diff.cpp11.basic">[[diff.cpp11.basic]]</a>
|
| 26 |
|
| 27 |
+
**Change:** New usual (non-placement) deallocator. **Rationale:**
|
| 28 |
+
Required for sized deallocation. **Effect on original feature:** Valid
|
| 29 |
+
C++11 code could declare a global placement allocation function and
|
| 30 |
+
deallocation function as follows:
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
void* operator new(std::size_t, std::size_t);
|
| 34 |
void operator delete(void*, std::size_t) noexcept;
|
| 35 |
```
|
| 36 |
|
| 37 |
In this International Standard, however, the declaration of
|
| 38 |
`operator delete` might match a predefined usual (non-placement)
|
| 39 |
+
`operator delete` [[basic.stc.dynamic]]. If so, the program is
|
| 40 |
ill-formed, as it was for class member allocation functions and
|
| 41 |
+
deallocation functions [[expr.new]].
|
| 42 |
|
| 43 |
+
### [[expr]]: expressions <a id="diff.cpp11.expr">[[diff.cpp11.expr]]</a>
|
| 44 |
|
| 45 |
+
**Change:** A conditional expression with a throw expression as its
|
| 46 |
+
second or third operand keeps the type and value category of the other
|
| 47 |
+
operand. **Rationale:** Formerly mandated conversions (lvalue-to-rvalue
|
| 48 |
+
[[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
|
| 49 |
+
[[conv.func]] standard conversions), especially the creation of the
|
| 50 |
+
temporary due to lvalue-to-rvalue conversion, were considered gratuitous
|
| 51 |
+
and surprising. **Effect on original feature:** Valid C++11 code that
|
| 52 |
+
relies on the conversions may behave differently in this International
|
| 53 |
+
Standard:
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
struct S {
|
| 57 |
int x = 1;
|
| 58 |
void mf() { x = 2; }
|
|
|
|
| 72 |
```
|
| 73 |
|
| 74 |
In C++11, the expression yields `sizeof(const char*)`. In this
|
| 75 |
International Standard, it yields `sizeof(const char[1])`.
|
| 76 |
|
| 77 |
+
### [[dcl.dcl]]: declarations <a id="diff.cpp11.dcl.dcl">[[diff.cpp11.dcl.dcl]]</a>
|
| 78 |
|
| 79 |
+
**Change:** `constexpr` non-static member functions are not implicitly
|
| 80 |
+
`const` member functions. **Rationale:** Necessary to allow `constexpr`
|
| 81 |
+
member functions to mutate the object. **Effect on original feature:**
|
| 82 |
+
Valid C++11 code may fail to compile in this International Standard. For
|
| 83 |
+
example, the following code is valid in C++11 but invalid in this
|
| 84 |
+
International Standard because it declares the same member function
|
| 85 |
+
twice with different return types:
|
| 86 |
|
| 87 |
``` cpp
|
| 88 |
struct S {
|
| 89 |
constexpr const int &f();
|
| 90 |
int &f();
|
| 91 |
};
|
| 92 |
```
|
| 93 |
|
| 94 |
+
**Change:** Classes with default member initializers can be aggregates.
|
| 95 |
+
**Rationale:** Necessary to allow default member initializers to be used
|
| 96 |
+
by aggregate initialization. **Effect on original feature:** Valid C++11
|
| 97 |
+
code may fail to compile or may change meaning in this International
|
| 98 |
+
Standard. For example:
|
|
|
|
|
|
|
| 99 |
|
| 100 |
``` cpp
|
| 101 |
+
struct S { // Aggregate in C++14{} onwards.
|
| 102 |
int m = 1;
|
| 103 |
};
|
| 104 |
struct X {
|
| 105 |
operator int();
|
| 106 |
operator S();
|
| 107 |
};
|
| 108 |
X a{};
|
| 109 |
+
S b{a}; // uses copy constructor in C++11{},
|
| 110 |
// performs aggregate initialization in this International Standard
|
| 111 |
```
|
| 112 |
|
| 113 |
+
### [[library]]: library introduction <a id="diff.cpp11.library">[[diff.cpp11.library]]</a>
|
| 114 |
|
| 115 |
+
**Change:** New header. **Rationale:** New functionality. **Effect on
|
| 116 |
+
original feature:** The C++ header `<shared_mutex>` is new. Valid C++11
|
| 117 |
+
code that `#include`s a header with that name may be invalid in this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
International Standard.
|
| 119 |
|
| 120 |
+
### [[input.output]]: input/output library <a id="diff.cpp11.input.output">[[diff.cpp11.input.output]]</a>
|
| 121 |
+
|
| 122 |
+
**Change:** `gets` is not defined. **Rationale:** Use of `gets` is
|
| 123 |
+
considered dangerous. **Effect on original feature:** Valid C++11 code
|
| 124 |
+
that uses the `gets` function may fail to compile in this International
|
| 125 |
+
Standard.
|
| 126 |
+
|