tmp/tmp8hsxib4x/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
### [[lex]]: lexical conventions <a id="diff.cpp17.lex">[[diff.cpp17.lex]]</a>
|
| 2 |
|
| 3 |
**Change:** New identifiers with special meaning. **Rationale:**
|
| 4 |
Required for new features. **Effect on original feature:** Logical lines
|
| 5 |
beginning with `module` or `import` may be interpreted differently in
|
| 6 |
-
this revision of C++.
|
|
|
|
|
|
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
class module {};
|
| 10 |
module m1; // was variable declaration; now module-declaration
|
| 11 |
module *m2; // variable declaration
|
|
@@ -13,21 +15,27 @@ module *m2; // variable declaration
|
|
| 13 |
class import {};
|
| 14 |
import j1; // was variable declaration; now module-import-declaration
|
| 15 |
::import j2; // variable declaration
|
| 16 |
```
|
| 17 |
|
|
|
|
|
|
|
| 18 |
**Change:** *header-name* tokens are formed in more contexts.
|
| 19 |
**Rationale:** Required for new features. **Effect on original
|
| 20 |
feature:** When the identifier `import` is followed by a `<` character,
|
| 21 |
-
a *header-name* token may be formed.
|
|
|
|
|
|
|
| 22 |
|
| 23 |
``` cpp
|
| 24 |
template<typename> class import {};
|
| 25 |
import<int> f(); // ill-formed; previously well-formed
|
| 26 |
::import<int> g(); // OK
|
| 27 |
```
|
| 28 |
|
|
|
|
|
|
|
| 29 |
**Change:** New keywords. **Rationale:** Required for new features.
|
| 30 |
|
| 31 |
- The `char8_t` keyword is added to differentiate the types of ordinary
|
| 32 |
and UTF-8 literals [[lex.string]].
|
| 33 |
- The `concept` keyword is added to enable the definition of concepts
|
|
@@ -47,29 +55,34 @@ Valid C++17 code using `char8_t`, `concept`, `consteval`, `constinit`,
|
|
| 47 |
not valid in this revision of C++.
|
| 48 |
|
| 49 |
**Change:** New operator `<=>`. **Rationale:** Necessary for new
|
| 50 |
functionality. **Effect on original feature:** Valid C++17 code that
|
| 51 |
contains a `<=` token immediately followed by a `>` token may be
|
| 52 |
-
ill-formed or have different semantics in this revision of C++.
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
namespace N {
|
| 57 |
struct X {};
|
| 58 |
bool operator<=(X, X);
|
| 59 |
template<bool(X, X)> struct Y {};
|
| 60 |
Y<operator<=> y; // ill-formed; previously well-formed
|
| 61 |
}
|
| 62 |
```
|
| 63 |
|
|
|
|
|
|
|
| 64 |
**Change:** Type of UTF-8 string and character literals. **Rationale:**
|
| 65 |
Required for new features. The changed types enable function
|
| 66 |
overloading, template specialization, and type deduction to distinguish
|
| 67 |
ordinary and UTF-8 string and character literals. **Effect on original
|
| 68 |
feature:** Valid C++17 code that depends on UTF-8 string literals having
|
| 69 |
type “array of `const char`” and UTF-8 character literals having type
|
| 70 |
-
“`char`” is not valid in this revision of C++.
|
|
|
|
|
|
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*
|
| 74 |
const char *ps = u8s; // ill-formed; previously well-formed
|
| 75 |
|
|
@@ -86,5 +99,7 @@ template<> struct ct<char> {
|
|
| 86 |
using type = char;
|
| 87 |
};
|
| 88 |
ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed.
|
| 89 |
```
|
| 90 |
|
|
|
|
|
|
|
|
|
| 1 |
### [[lex]]: lexical conventions <a id="diff.cpp17.lex">[[diff.cpp17.lex]]</a>
|
| 2 |
|
| 3 |
**Change:** New identifiers with special meaning. **Rationale:**
|
| 4 |
Required for new features. **Effect on original feature:** Logical lines
|
| 5 |
beginning with `module` or `import` may be interpreted differently in
|
| 6 |
+
this revision of C++.
|
| 7 |
+
|
| 8 |
+
[*Example 1*:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
class module {};
|
| 12 |
module m1; // was variable declaration; now module-declaration
|
| 13 |
module *m2; // variable declaration
|
|
|
|
| 15 |
class import {};
|
| 16 |
import j1; // was variable declaration; now module-import-declaration
|
| 17 |
::import j2; // variable declaration
|
| 18 |
```
|
| 19 |
|
| 20 |
+
— *end example*]
|
| 21 |
+
|
| 22 |
**Change:** *header-name* tokens are formed in more contexts.
|
| 23 |
**Rationale:** Required for new features. **Effect on original
|
| 24 |
feature:** When the identifier `import` is followed by a `<` character,
|
| 25 |
+
a *header-name* token may be formed.
|
| 26 |
+
|
| 27 |
+
[*Example 2*:
|
| 28 |
|
| 29 |
``` cpp
|
| 30 |
template<typename> class import {};
|
| 31 |
import<int> f(); // ill-formed; previously well-formed
|
| 32 |
::import<int> g(); // OK
|
| 33 |
```
|
| 34 |
|
| 35 |
+
— *end example*]
|
| 36 |
+
|
| 37 |
**Change:** New keywords. **Rationale:** Required for new features.
|
| 38 |
|
| 39 |
- The `char8_t` keyword is added to differentiate the types of ordinary
|
| 40 |
and UTF-8 literals [[lex.string]].
|
| 41 |
- The `concept` keyword is added to enable the definition of concepts
|
|
|
|
| 55 |
not valid in this revision of C++.
|
| 56 |
|
| 57 |
**Change:** New operator `<=>`. **Rationale:** Necessary for new
|
| 58 |
functionality. **Effect on original feature:** Valid C++17 code that
|
| 59 |
contains a `<=` token immediately followed by a `>` token may be
|
| 60 |
+
ill-formed or have different semantics in this revision of C++.
|
| 61 |
+
|
| 62 |
+
[*Example 3*:
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
namespace N {
|
| 66 |
struct X {};
|
| 67 |
bool operator<=(X, X);
|
| 68 |
template<bool(X, X)> struct Y {};
|
| 69 |
Y<operator<=> y; // ill-formed; previously well-formed
|
| 70 |
}
|
| 71 |
```
|
| 72 |
|
| 73 |
+
— *end example*]
|
| 74 |
+
|
| 75 |
**Change:** Type of UTF-8 string and character literals. **Rationale:**
|
| 76 |
Required for new features. The changed types enable function
|
| 77 |
overloading, template specialization, and type deduction to distinguish
|
| 78 |
ordinary and UTF-8 string and character literals. **Effect on original
|
| 79 |
feature:** Valid C++17 code that depends on UTF-8 string literals having
|
| 80 |
type “array of `const char`” and UTF-8 character literals having type
|
| 81 |
+
“`char`” is not valid in this revision of C++.
|
| 82 |
+
|
| 83 |
+
[*Example 4*:
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*
|
| 87 |
const char *ps = u8s; // ill-formed; previously well-formed
|
| 88 |
|
|
|
|
| 99 |
using type = char;
|
| 100 |
};
|
| 101 |
ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed.
|
| 102 |
```
|
| 103 |
|
| 104 |
+
— *end example*]
|
| 105 |
+
|