From Jason Turner

[diff.cpp17.lex]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpz0x3f5ah/{from.md → to.md} +97 -0
tmp/tmpz0x3f5ah/{from.md → to.md} RENAMED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 International Standard.
7
+
8
+ [*Example 1*:
9
+
10
+ ``` cpp
11
+ class module {};
12
+ module m1; // was variable declaration; now module-declaration
13
+ module *m2; // variable declaration
14
+
15
+ class import {};
16
+ import j1; // was variable declaration; now 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
42
+ [[temp.concept]].
43
+ - The `consteval` keyword is added to declare immediate functions
44
+ [[dcl.constexpr]].
45
+ - The `constinit` keyword is added to prevent unintended dynamic
46
+ initialization [[dcl.constinit]].
47
+ - The `co_await`, `co_yield`, and `co_return` keywords are added to
48
+ enable the definition of coroutines [[dcl.fct.def.coroutine]].
49
+ - The `requires` keyword is added to introduce constraints through a
50
+ *requires-clause* [[temp.pre]] or a *requires-expression*
51
+ [[expr.prim.req]].
52
+
53
+ Valid C++17 code using `char8_t`, `concept`, `consteval`, `constinit`,
54
+ `co_await`, `co_yield`, `co_return`, or `requires` as an identifier is
55
+ not valid in this International Standard.
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 International Standard:
61
+
62
+ ``` cpp
63
+ namespace N {
64
+ struct X {};
65
+ bool operator<=(X, X);
66
+ template<bool(X, X)> struct Y {};
67
+ Y<operator<=> y; // ill-formed; previously well-formed
68
+ }
69
+ ```
70
+
71
+ **Change:** Type of UTF-8 string and character literals. **Rationale:**
72
+ Required for new features. The changed types enable function
73
+ overloading, template specialization, and type deduction to distinguish
74
+ ordinary and UTF-8 string and character literals. **Effect on original
75
+ feature:** Valid C++17 code that depends on UTF-8 string literals having
76
+ type “array of `const char`” and UTF-8 character literals having type
77
+ “`char`” is not valid in this International Standard.
78
+
79
+ ``` cpp
80
+ const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*
81
+ const char *ps = u8s; // ill-formed; previously well-formed
82
+
83
+ auto u8c = u8'c'; // u8c previously deduced as char; now deduced as char8_t
84
+ char *pc = &u8c; // ill-formed; previously well-formed
85
+
86
+ std::string s = u8"text"; // ill-formed; previously well-formed
87
+
88
+ void f(const char *s);
89
+ f(u8"text"); // ill-formed; previously well-formed
90
+
91
+ template<typename> struct ct;
92
+ template<> struct ct<char> {
93
+ using type = char;
94
+ };
95
+ ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed.
96
+ ```
97
+