[diff.cpp17.lex]

# Annex C (informative) Compatibility [[diff]](./#diff)

## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#lex)

### C.3.2 [[lex]](lex "5 Lexical conventions"): lexical conventions [diff.cpp17.lex]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L843)

**Affected subclauses:** [[lex.pptoken]](lex.pptoken), [[module.unit]](module.unit), [[module.import]](module.import), [[cpp.pre]](cpp.pre), [[cpp.module]](cpp.module), and [[cpp.import]](cpp.import)  


**Change:** New identifiers with special meaning[.](#1.sentence-1)

  


**Rationale:** Required for new features[.](#1.sentence-2)

  


**Effect on original feature:** Logical lines beginning withmodule or import may
be interpreted differently
in this revision of C++[.](#1.sentence-3)

[*Example [1](#example-1)*: class module {};module m1; // was variable declaration; now [*module-declaration*](module.unit#nt:module-declaration "10.1 Module units and purviews [module.unit]")module *m2; // variable declarationclass import {};import j1; // was variable declaration; now [*module-import-declaration*](module.import#nt:module-import-declaration "10.3 Import declaration [module.import]")::import j2; // variable declaration â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L865)

**Affected subclause:** [[lex.header]](lex.header)  


**Change:** [*header-name*](lex.header#nt:header-name "5.6 Header names [lex.header]") tokens are formed in more contexts[.](#2.sentence-1)

  


**Rationale:** Required for new features[.](#2.sentence-2)

  


**Effect on original feature:** When the identifier import is followed by a < character,
a [*header-name*](lex.header#nt:header-name "5.6 Header names [lex.header]") token may be formed[.](#2.sentence-3)

[*Example [2](#example-2)*: template<typename> class import {};import<int> f(); // ill-formed; previously well-formed::import<int> g(); // OK â *end example*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L882)

**Affected subclause:** [[lex.key]](lex.key)  


**Change:** New keywords[.](#3.sentence-1)

  


**Rationale:** Required for new features[.](#3.sentence-2)

- [(3.1)](#3.1)

  The char8_t keyword is added to differentiate
the types of ordinary and UTF-8 literals ([[lex.string]](lex.string "5.13.5 String literals"))[.](#3.1.sentence-1)

- [(3.2)](#3.2)

  The concept keyword is
added to enable the definition of concepts ([[temp.concept]](temp.concept "13.7.9 Concept definitions"))[.](#3.2.sentence-1)

- [(3.3)](#3.3)

  The consteval keyword is added to
declare immediate functions ([[dcl.constexpr]](dcl.constexpr "9.2.6 The constexpr and consteval specifiers"))[.](#3.3.sentence-1)

- [(3.4)](#3.4)

  The constinit keyword is added to
prevent unintended dynamic initialization ([[dcl.constinit]](dcl.constinit "9.2.7 The constinit specifier"))[.](#3.4.sentence-1)

- [(3.5)](#3.5)

  The co_await, co_yield, and co_return keywords are added
to enable the definition of coroutines ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4 Coroutine definitions"))[.](#3.5.sentence-1)

- [(3.6)](#3.6)

  The requires keyword is added
to introduce constraints through a [*requires-clause*](temp.pre#nt:requires-clause "13.1 Preamble [temp.pre]") ([[temp.pre]](temp.pre "13.1 Preamble"))
or a [*requires-expression*](expr.prim.req.general#nt:requires-expression "7.5.8.1 General [expr.prim.req.general]") ([[expr.prim.req]](expr.prim.req "7.5.8 Requires expressions"))[.](#3.6.sentence-1)

**Effect on original feature:** Valid C++ 2017 code usingchar8_t,concept,consteval,constinit,co_await, co_yield, co_return,
or requires as an identifier is not valid in this revision of C++[.](#3.sentence-3)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L919)

**Affected subclause:** [[lex.operators]](lex.operators)  


**Change:** New operator <=>[.](#4.sentence-1)

  


**Rationale:** Necessary for new functionality[.](#4.sentence-2)

  


**Effect on original feature:** Valid C++ 2017 code that contains a <= token
immediately followed by a > token
may be ill-formed or have different semantics in this revision of C++[.](#4.sentence-3)

[*Example [3](#example-3)*: namespace N {struct X {}; bool operator<=(X, X); template<bool(X, X)> struct Y {};
 Y<operator<=> y; // ill-formed; previously well-formed} â *end example*]

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L939)

**Affected subclause:** [[lex.literal]](lex.literal)  


**Change:** Type of UTF-8 string and character literals[.](#5.sentence-1)

  


**Rationale:** Required for new features[.](#5.sentence-2)

The changed types enable function overloading, template specialization, and
type deduction to distinguish ordinary and UTF-8 string and character literals[.](#5.sentence-3)

  


**Effect on original feature:** Valid C++ 2017 code that depends on
UTF-8 string literals having type âarray of const charâ and
UTF-8 character literals having type âcharâ
is not valid in this revision of C++[.](#5.sentence-4)

[*Example [4](#example-4)*: const auto *u8s = u8"text"; // u8s previously deduced as const char*; now deduced as const char8_t*const char *ps = u8s; // ill-formed; previously well-formedauto u8c = u8'c'; // u8c previously deduced as char; now deduced as char8_tchar *pc = &u8c; // ill-formed; previously well-formed std::string s = u8"text"; // ill-formed; previously well-formedvoid f(const char *s);
f(u8"text"); // ill-formed; previously well-formedtemplate<typename> struct ct;template<> struct ct<char> {using type = char;};
ct<decltype(u8'c')>::type x; // ill-formed; previously well-formed. â *end example*]
