Files
cppdraft_translate/cppdraft/lex/literal.md
2025-10-25 03:02:53 +03:00

993 lines
66 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[lex.literal]
# 5 Lexical conventions [[lex]](./#lex)
## 5.13 Literals [lex.literal]
### [5.13.1](#kinds) Kinds of literals [[lex.literal.kinds]](lex.literal.kinds)
[1](#kinds-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1146)
There are several kinds of literals[.](#kinds-1.sentence-1)[14](#footnote-14 "The term “literal” generally designates, in this document, those tokens that are called “constants” in C.")
[literal:](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]")
[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")
[*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")
[*boolean-literal*](#nt:boolean-literal "5.13.7Boolean literals[lex.bool]")
[*pointer-literal*](#nt:pointer-literal "5.13.8Pointer literals[lex.nullptr]")
[*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]")
[*Note [1](#kinds-note-1)*:
When appearing as an [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]"),
a literal has a type and a value category ([[expr.prim.literal]](expr.prim.literal "7.5.2Literals"))[.](#kinds-1.sentence-2)
— *end note*]
[14)](#footnote-14)[14)](#footnoteref-14)
The term “literal” generally designates, in this
document, those tokens that are called “constants” in C[.](#footnote-14.sentence-1)
### [5.13.2](#lex.icon) Integer literals [[lex.icon]](lex.icon)
[integer-literal:](#nt:integer-literal "5.13.2Integer literals[lex.icon]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")opt
[binary-literal:](#nt:binary-literal "5.13.2Integer literals[lex.icon]")
0b [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
0B [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") 'opt [*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")
[octal-literal:](#nt:octal-literal "5.13.2Integer literals[lex.icon]")
0
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") 'opt [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
[decimal-literal:](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")
[*nonzero-digit*](#nt:nonzero-digit "5.13.2Integer literals[lex.icon]")
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") 'opt [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[hexadecimal-literal:](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[binary-digit:](#nt:binary-digit "5.13.2Integer literals[lex.icon]") one of
0 1
[octal-digit:](#nt:octal-digit "5.13.2Integer literals[lex.icon]") one of
0 1 2 3 4 5 6 7
[nonzero-digit:](#nt:nonzero-digit "5.13.2Integer literals[lex.icon]") one of
1 2 3 4 5 6 7 8 9
[hexadecimal-prefix:](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") one of
0x 0X
[hexadecimal-digit-sequence:](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") 'opt [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")
[hexadecimal-digit:](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]") one of
0 1 2 3 4 5 6 7 8 9
a b c d e f
A B C D E F
[integer-suffix:](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*long-suffix*](#nt:long-suffix "5.13.2Integer literals[lex.icon]")opt
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*long-long-suffix*](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]")opt
[*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") [*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]")opt
[*long-suffix*](#nt:long-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[*long-long-suffix*](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]") [*unsigned-suffix*](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]")opt
[unsigned-suffix:](#nt:unsigned-suffix "5.13.2Integer literals[lex.icon]") one of
u U
[long-suffix:](#nt:long-suffix "5.13.2Integer literals[lex.icon]") one of
l L
[long-long-suffix:](#nt:long-long-suffix "5.13.2Integer literals[lex.icon]") one of
ll LL
[size-suffix:](#nt:size-suffix "5.13.2Integer literals[lex.icon]") one of
z Z
[1](#lex.icon-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1268)
In an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]"),
the sequence of[*binary-digit*](#nt:binary-digit "5.13.2Integer literals[lex.icon]")*s*,[*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s*,[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s*, or[*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* is interpreted as a base N integer as shown in Table [7](#tab:lex.icon.base "Table 7: Base of integer-literals");
the lexically first digit of the sequence of digits is the most significant[.](#lex.icon-1.sentence-1)
[*Note [1](#lex.icon-note-1)*:
The prefix and any optional separating single quotes are ignored
when determining the value[.](#lex.icon-1.sentence-2)
— *end note*]
Table [7](#tab:lex.icon.base) — Base of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* [[tab:lex.icon.base]](./tab:lex.icon.base)
| [🔗](#tab:lex.icon.base-row-1)<br>**Kind of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")** | **base N** |
| --- | --- |
| [🔗](#tab:lex.icon.base-row-2)<br>[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") | 2 |
| [🔗](#tab:lex.icon.base-row-3)<br>[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") | 8 |
| [🔗](#tab:lex.icon.base-row-4)<br>[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") | 10 |
| [🔗](#tab:lex.icon.base-row-5)<br>[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") | 16 |
[2](#lex.icon-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1297)
The [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s*a through f and A through F have decimal values ten through fifteen[.](#lex.icon-2.sentence-1)
[*Example [1](#lex.icon-example-1)*:
The number twelve can be written 12, 014,0XC, or 0b1100[.](#lex.icon-2.sentence-2)
The [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* 1048576,1'048'576, 0X100000, 0x10'0000, and0'004'000'000 all have the same value[.](#lex.icon-2.sentence-3)
— *end example*]
[3](#lex.icon-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1308)
The type of an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") is
the first type in the list in Table [8](#tab:lex.icon.type "Table 8: Types of integer-literals") corresponding to its optional [*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]") in which its value can be represented[.](#lex.icon-3.sentence-1)
Table [8](#tab:lex.icon.type) — Types of [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* [[tab:lex.icon.type]](./tab:lex.icon.type)
| [🔗](#tab:lex.icon.type-row-1)<br>**[*integer-suffix*](#nt:integer-suffix "5.13.2Integer literals[lex.icon]")** | **[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")** | **[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") other than [*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]")** |
| --- | --- | --- |
| [🔗](#tab:lex.icon.type-row-2)<br>none | int | int |
| [🔗](#tab:lex.icon.type-row-3) | long int | unsigned int |
| [🔗](#tab:lex.icon.type-row-4) | long long int | long int |
| [🔗](#tab:lex.icon.type-row-5) | | unsigned long int |
| [🔗](#tab:lex.icon.type-row-6) | | long long int |
| [🔗](#tab:lex.icon.type-row-7) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-8)<br>u or U | unsigned int | unsigned int |
| [🔗](#tab:lex.icon.type-row-9) | unsigned long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-10) | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-11)<br>l or L | long int | long int |
| [🔗](#tab:lex.icon.type-row-12) | long long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-13) | | long long int |
| [🔗](#tab:lex.icon.type-row-14) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-15)<br>Both u or U | unsigned long int | unsigned long int |
| [🔗](#tab:lex.icon.type-row-16)<br>and l or L | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-17)<br>ll or LL | long long int | long long int |
| [🔗](#tab:lex.icon.type-row-18) | | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-19)<br>Both u or U | unsigned long long int | unsigned long long int |
| [🔗](#tab:lex.icon.type-row-20)<br>and ll or LL | | |
| [🔗](#tab:lex.icon.type-row-21)<br>z or Z | the signed integer type corresponding | the signed integer type |
| [🔗](#tab:lex.icon.type-row-22) | to std::size_t ([[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets")) | corresponding to std::size_t |
| [🔗](#tab:lex.icon.type-row-23) | | std::size_t |
| [🔗](#tab:lex.icon.type-row-24)<br>Both u or U | std::size_t | std::size_t |
| [🔗](#tab:lex.icon.type-row-25)<br>and z or Z | | |
[4](#lex.icon-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1399)
Except for [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")*s* containing
a [*size-suffix*](#nt:size-suffix "5.13.2Integer literals[lex.icon]"),
if the value of an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") cannot be represented by any type in its list and
an extended integer type ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types")) can represent its value,
it may have that extended integer type[.](#lex.icon-4.sentence-1)
If all of the types in the list for the [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") are signed,
the extended integer type is signed[.](#lex.icon-4.sentence-2)
If all of the types in the list for the [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") are unsigned,
the extended integer type is unsigned[.](#lex.icon-4.sentence-3)
If the list contains both signed and unsigned types,
the extended integer type may be signed or unsigned[.](#lex.icon-4.sentence-4)
If an [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") cannot be represented by any of the allowed types,
the program is ill-formed[.](#lex.icon-4.sentence-5)
[*Note [2](#lex.icon-note-2)*:
An [*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]") with a z or Z suffix
is ill-formed if it cannot be represented by std::size_t[.](#lex.icon-4.sentence-6)
— *end note*]
### [5.13.3](#lex.ccon) Character literals [[lex.ccon]](lex.ccon)
[character-literal:](#nt:character-literal "5.13.3Character literals[lex.ccon]")
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt ' [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") '
[encoding-prefix:](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") one of
u8 u U L
[c-char-sequence:](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]")
[*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]") [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]")opt
[c-char:](#nt:c-char "5.13.3Character literals[lex.ccon]")
[*basic-c-char*](#nt:basic-c-char "5.13.3Character literals[lex.ccon]")
[*escape-sequence*](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
[basic-c-char:](#nt:basic-c-char "5.13.3Character literals[lex.ccon]")
any member of the translation character set except the U+0027 apostrophe,
U+005c reverse solidus, or new-line character
[escape-sequence:](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")
[*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]")
[*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]")
[simple-escape-sequence:](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*simple-escape-sequence-char*](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]")
[simple-escape-sequence-char:](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]") one of
' " ? \ a b f n r t v
[numeric-escape-sequence:](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]")
[*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]")
[*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")
[simple-octal-digit-sequence:](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]")
[*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*simple-octal-digit-sequence*](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]")opt
[octal-escape-sequence:](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\ [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\ [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]") [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")
\o{ [*simple-octal-digit-sequence*](#nt:simple-octal-digit-sequence "5.13.3Character literals[lex.ccon]") }
[hexadecimal-escape-sequence:](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")
\x [*simple-hexadecimal-digit-sequence*](lex.universal.char#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]")
\x{ [*simple-hexadecimal-digit-sequence*](lex.universal.char#nt:simple-hexadecimal-digit-sequence "5.3.2Universal character names[lex.universal.char]") }
[conditional-escape-sequence:](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]")
\ [*conditional-escape-sequence-char*](#nt:conditional-escape-sequence-char "5.13.3Character literals[lex.ccon]")
[conditional-escape-sequence-char:](#nt:conditional-escape-sequence-char "5.13.3Character literals[lex.ccon]")
any member of the basic character set that is not an [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]"), a [*simple-escape-sequence-char*](#nt:simple-escape-sequence-char "5.13.3Character literals[lex.ccon]"), or the characters N, o, u, U, or x
[1](#lex.ccon-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1505)
A [*multicharacter literal*](#def:literal,multicharacter "5.13.3Character literals[lex.ccon]") is a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") whose [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consists of
more than one [*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]")[.](#lex.ccon-1.sentence-1)
A multicharacter literal shall not have an [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#lex.ccon-1.sentence-2)
If a multicharacter literal contains a [*c-char*](#nt:c-char "5.13.3Character literals[lex.ccon]") that is not encodable as a single code unit in the ordinary literal encoding,
the program is ill-formed[.](#lex.ccon-1.sentence-3)
Multicharacter literals are conditionally-supported[.](#lex.ccon-1.sentence-4)
[2](#lex.ccon-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1525)
The kind of a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]"),
its type, and its associated character encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))
are determined by
its [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") and its [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") as defined by Table [9](#tab:lex.ccon.literal "Table 9: Character literals")[.](#lex.ccon-2.sentence-1)
Table [9](#tab:lex.ccon.literal) — Character literals [[tab:lex.ccon.literal]](./tab:lex.ccon.literal)
| [🔗](#tab:lex.ccon.literal-row-1)<br>**Encoding** | **Kind** | **Type** | **Associated char-** | **Example** |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.ccon.literal-row-2)<br>**prefix** | | | **acter encoding** | |
| [🔗](#tab:lex.ccon.literal-row-3)<br>none | [*ordinary character literal*](#def:literal,character,ordinary "5.13.3Character literals[lex.ccon]") | char | ordinary literal | 'v' |
| [🔗](#tab:lex.ccon.literal-row-4)<br> | multicharacter literal | int | encoding | 'abcd' |
| [🔗](#tab:lex.ccon.literal-row-5)<br>L | [*wide character literal*](#def:literal,character,wide "5.13.3Character literals[lex.ccon]") | wchar_t | wide literal | L'w' |
| [🔗](#tab:lex.ccon.literal-row-6) | | | encoding | |
| [🔗](#tab:lex.ccon.literal-row-7)<br>u8 | [*UTF-8 character literal*](#def:literal,character,UTF-8 "5.13.3Character literals[lex.ccon]") | char8_t | UTF-8 | u8'x' |
| [🔗](#tab:lex.ccon.literal-row-8)<br>u | [*UTF-16 character literal*](#def:literal,character,UTF-16 "5.13.3Character literals[lex.ccon]") | char16_t | UTF-16 | u'y' |
| [🔗](#tab:lex.ccon.literal-row-9)<br>U | [*UTF-32 character literal*](#def:literal,character,UTF-32 "5.13.3Character literals[lex.ccon]") | char32_t | UTF-32 | U'z' |
[3](#lex.ccon-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1571)
In translation phase 4,
the value of a [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") is determined
using the range of representable values
of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type in translation phase 7[.](#lex.ccon-3.sentence-1)
A multicharacter literal has animplementation-defined
value[.](#lex.ccon-3.sentence-2)
The value of any other kind of [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") is determined as follows:
- [(3.1)](#lex.ccon-3.1)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of a single[*basic-c-char*](#nt:basic-c-char "5.13.3Character literals[lex.ccon]"),[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]"), or[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") is the code unit value of the specified character
as encoded in the literal's associated character encoding[.](#lex.ccon-3.1.sentence-1)
If the specified character lacks
representation in the literal's associated character encoding or
if it cannot be encoded as a single code unit,
then the program is ill-formed[.](#lex.ccon-3.1.sentence-2)
- [(3.2)](#lex.ccon-3.2)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of
a single [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") has a value as follows:
* [(3.2.1)](#lex.ccon-3.2.1)
Let v be the integer value represented by
the octal number comprising
the sequence of [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s* in
an [*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]") or by
the hexadecimal number comprising
the sequence of [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in
a [*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")[.](#lex.ccon-3.2.1.sentence-1)
* [(3.2.2)](#lex.ccon-3.2.2)
If v does not exceed
the range of representable values of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type,
then the value is v[.](#lex.ccon-3.2.2.sentence-1)
* [(3.2.3)](#lex.ccon-3.2.3)
Otherwise,
if the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is absent or L, andv does not exceed the range of representable values of the corresponding unsigned type for the underlying type of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type,
then the value is the unique value of the [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]")'s type T that is congruent to v modulo 2N, where N is the width of T[.](#lex.ccon-3.2.3.sentence-1)
* [(3.2.4)](#lex.ccon-3.2.4)
Otherwise, the program is ill-formed[.](#lex.ccon-3.2.4.sentence-1)
- [(3.3)](#lex.ccon-3.3)
A [*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") with
a [*c-char-sequence*](#nt:c-char-sequence "5.13.3Character literals[lex.ccon]") consisting of
a single [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") is conditionally-supported and
has an implementation-defined value[.](#lex.ccon-3.3.sentence-1)
[4](#lex.ccon-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1629)
The character specified by a [*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]") is specified in Table [10](#tab:lex.ccon.esc "Table 10: Simple escape sequences")[.](#lex.ccon-4.sentence-1)
[*Note [1](#lex.ccon-note-1)*:
Using an escape sequence for a question mark
is supported for compatibility with C++ 2014 and C[.](#lex.ccon-4.sentence-2)
— *end note*]
Table [10](#tab:lex.ccon.esc) — Simple escape sequences [[tab:lex.ccon.esc]](./tab:lex.ccon.esc)
| [🔗](#tab:lex.ccon.esc-row-1)<br>**character** | | **[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")** |
| --- | --- | --- |
| [🔗](#tab:lex.ccon.esc-row-2)<br>U+000a | line feed | \n |
| [🔗](#tab:lex.ccon.esc-row-3)<br>U+0009 | character tabulation | \t |
| [🔗](#tab:lex.ccon.esc-row-4)<br>U+000b | line tabulation | \v |
| [🔗](#tab:lex.ccon.esc-row-5)<br>U+0008 | backspace | \b |
| [🔗](#tab:lex.ccon.esc-row-6)<br>U+000d | carriage return | \r |
| [🔗](#tab:lex.ccon.esc-row-7)<br>U+000c | form feed | \f |
| [🔗](#tab:lex.ccon.esc-row-8)<br>U+0007 | alert | \a |
| [🔗](#tab:lex.ccon.esc-row-9)<br>U+005c | reverse solidus | \\ |
| [🔗](#tab:lex.ccon.esc-row-10)<br>U+003f | question mark | \? |
| [🔗](#tab:lex.ccon.esc-row-11)<br>U+0027 | apostrophe | \' |
| [🔗](#tab:lex.ccon.esc-row-12)<br>U+0022 | quotation mark | \" |
### [5.13.4](#lex.fcon) Floating-point literals [[lex.fcon]](lex.fcon)
[floating-point-literal:](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[decimal-floating-point-literal:](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")opt [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[hexadecimal-floating-point-literal:](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")opt
[fractional-constant:](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")opt . [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") .
[hexadecimal-fractional-constant:](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")opt . [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]")
[*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") .
[exponent-part:](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")
e [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
E [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[binary-exponent-part:](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]")
p [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
P [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[sign:](#nt:sign "5.13.4Floating-point literals[lex.fcon]") one of
+ -
[digit-sequence:](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]")
[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") 'opt [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")
[floating-point-suffix:](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]") one of
f l f16 f32 f64 f128 bf16 F L F16 F32 F64 F128 BF16
[1](#lex.fcon-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1718)
The type of
a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"), [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types"))
is determined by
its [*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]") as specified in Table [11](#tab:lex.fcon.type "Table 11: Types of floating-point-literals")[.](#lex.fcon-1.sentence-1)
[*Note [1](#lex.fcon-note-1)*:
The floating-point suffixesf16, f32, f64, f128, bf16,F16, F32, F64, F128, and BF16 are conditionally-supported[.](#lex.fcon-1.sentence-2)
See [[basic.extended.fp]](basic.extended.fp "6.9.3Optional extended floating-point types")[.](#lex.fcon-1.sentence-3)
— *end note*]
Table [11](#tab:lex.fcon.type) — Types of [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s* [[tab:lex.fcon.type]](./tab:lex.fcon.type)
| [🔗](#tab:lex.fcon.type-row-1)<br>**[*floating-point-suffix*](#nt:floating-point-suffix "5.13.4Floating-point literals[lex.fcon]")** | **type** |
| --- | --- |
| [🔗](#tab:lex.fcon.type-row-2)<br>none | double |
| [🔗](#tab:lex.fcon.type-row-3)<br>f or F | float |
| [🔗](#tab:lex.fcon.type-row-4)<br>l or L | long double |
| [🔗](#tab:lex.fcon.type-row-5)<br>f16 or F16 | std::float16_t |
| [🔗](#tab:lex.fcon.type-row-6)<br>f32 or F32 | std::float32_t |
| [🔗](#tab:lex.fcon.type-row-7)<br>f64 or F64 | std::float64_t |
| [🔗](#tab:lex.fcon.type-row-8)<br>f128 or F128 | std::float128_t |
| [🔗](#tab:lex.fcon.type-row-9)<br>bf16 or BF16 | std::bfloat16_t |
[2](#lex.fcon-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1752)
The [*significand*](#def:significand "5.13.4Floating-point literals[lex.fcon]") of a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the [*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") or [*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") of a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") or the [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") or [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") of a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#lex.fcon-2.sentence-1)
In the significand,
the sequence of [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* or [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* and optional period are interpreted as a base N real number s,
where N is 10 for a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") and
16 for a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#lex.fcon-2.sentence-2)
[*Note [2](#lex.fcon-note-2)*:
Any optional separating single quotes are ignored when determining the value[.](#lex.fcon-2.sentence-3)
— *end note*]
If an [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") or [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") is present,
the exponent e of the [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the result of interpreting
the sequence of an optional [*sign*](#nt:sign "5.13.4Floating-point literals[lex.fcon]") and the [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* as a base 10 integer[.](#lex.fcon-2.sentence-4)
Otherwise, the exponent e is 0[.](#lex.fcon-2.sentence-5)
The scaled value of the literal iss×10e for a [*decimal-floating-point-literal*](#nt:decimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]") ands×2e for a [*hexadecimal-floating-point-literal*](#nt:hexadecimal-floating-point-literal "5.13.4Floating-point literals[lex.fcon]")[.](#lex.fcon-2.sentence-6)
[*Example [1](#lex.fcon-example-1)*:
The [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*49.625 and 0xC.68p+2 have the same value[.](#lex.fcon-2.sentence-7)
The [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]")*s*1.602'176'565e-19 and 1.602176565e-19 have the same value[.](#lex.fcon-2.sentence-8)
— *end example*]
[3](#lex.fcon-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1786)
If the scaled value is not in the range of representable
values for its type, the program is ill-formed[.](#lex.fcon-3.sentence-1)
Otherwise, the value of a [*floating-point-literal*](#nt:floating-point-literal "5.13.4Floating-point literals[lex.fcon]") is the scaled value if representable,
else the larger or smaller representable value nearest the scaled value,
chosen in an implementation-defined manner[.](#lex.fcon-3.sentence-2)
### [5.13.5](#lex.string) String literals [[lex.string]](lex.string)
[string-literal:](#nt:string-literal "5.13.5String literals[lex.string]")
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt " [*s-char-sequence*](#nt:s-char-sequence "5.13.5String literals[lex.string]")opt "
[*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")opt R [*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]")
[s-char-sequence:](#nt:s-char-sequence "5.13.5String literals[lex.string]")
[*s-char*](#nt:s-char "5.13.5String literals[lex.string]") [*s-char-sequence*](#nt:s-char-sequence "5.13.5String literals[lex.string]")opt
[s-char:](#nt:s-char "5.13.5String literals[lex.string]")
[*basic-s-char*](#nt:basic-s-char "5.13.5String literals[lex.string]")
[*escape-sequence*](#nt:escape-sequence "5.13.3Character literals[lex.ccon]")
[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")
[basic-s-char:](#nt:basic-s-char "5.13.5String literals[lex.string]")
any member of the translation character set except the U+0022 quotation mark,
U+005c reverse solidus, or new-line character
[raw-string:](#nt:raw-string "5.13.5String literals[lex.string]")
" [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt ( [*r-char-sequence*](#nt:r-char-sequence "5.13.5String literals[lex.string]")opt ) [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt "
[r-char-sequence:](#nt:r-char-sequence "5.13.5String literals[lex.string]")
[*r-char*](#nt:r-char "5.13.5String literals[lex.string]") [*r-char-sequence*](#nt:r-char-sequence "5.13.5String literals[lex.string]")opt
[r-char:](#nt:r-char "5.13.5String literals[lex.string]")
any member of the translation character set, except a U+0029 right parenthesis followed by
the initial [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") (which may be empty) followed by a U+0022 quotation mark
[d-char-sequence:](#nt:d-char-sequence "5.13.5String literals[lex.string]")
[*d-char*](#nt:d-char "5.13.5String literals[lex.string]") [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")opt
[d-char:](#nt:d-char "5.13.5String literals[lex.string]")
any member of the basic character set except:
U+0020 space, U+0028 left parenthesis, U+0029 right parenthesis, U+005c reverse solidus,
U+0009 character tabulation, U+000b line tabulation, U+000c form feed, and new-line
[1](#lex.string-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1850)
The kind of a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]"),
its type, and
its associated character encoding ([[lex.charset]](lex.charset "5.3.1Character sets"))
are determined by its encoding prefix and sequence of[*s-char*](#nt:s-char "5.13.5String literals[lex.string]")*s* or [*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s* as defined by Table [12](#tab:lex.string.literal "Table 12: String literals") where n is the number of encoded code units
that would result from an evaluation of the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") (see below)[.](#lex.string-1.sentence-1)
Table [12](#tab:lex.string.literal) — String literals [[tab:lex.string.literal]](./tab:lex.string.literal)
| [🔗](#tab:lex.string.literal-row-1)<br>**Enco-** | **Kind** | **Type** | **Associated** | **Examples** |
| --- | --- | --- | --- | --- |
| [🔗](#tab:lex.string.literal-row-2)<br>**ding** | | | **character** | |
| [🔗](#tab:lex.string.literal-row-3)<br>**prefix** | | | **encoding** | |
| [🔗](#tab:lex.string.literal-row-4)<br>none | [*ordinary string literal*](#def:literal,string,ordinary "5.13.5String literals[lex.string]") | array of n const char | ordinary literal encoding | "ordinary string" R"(ordinary raw string)" |
| [🔗](#tab:lex.string.literal-row-5)<br>L | [*wide string literal*](#def:literal,string,wide "5.13.5String literals[lex.string]") | array of n const wchar_t | wide literal encoding | L"wide string" LR"w(wide raw string)w" |
| [🔗](#tab:lex.string.literal-row-6)<br>u8 | [*UTF-8 string literal*](#def:literal,string,UTF-8 "5.13.5String literals[lex.string]") | array of n const char8_t | UTF-8 | u8"UTF-8 string" u8R"x(UTF-8 raw string)x" |
| [🔗](#tab:lex.string.literal-row-7)<br>u | [*UTF-16 string literal*](#def:literal,string,UTF-16 "5.13.5String literals[lex.string]") | array of n const char16_t | UTF-16 | u"UTF-16 string" uR"y(UTF-16 raw string)y" |
| [🔗](#tab:lex.string.literal-row-8)<br>U | [*UTF-32 string literal*](#def:literal,string,UTF-32 "5.13.5String literals[lex.string]") | array of n const char32_t | UTF-32 | U"UTF-32 string" UR"z(UTF-32 raw string)z" |
[2](#lex.string-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1909)
A [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") that has an Rin the prefix is a [*raw string literal*](#def:raw_string_literal "5.13.5String literals[lex.string]")[.](#lex.string-2.sentence-1)
The[*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") serves as a delimiter[.](#lex.string-2.sentence-2)
The terminating[*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") of a [*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]") is the same sequence of
characters as the initial [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]")[.](#lex.string-2.sentence-3)
A [*d-char-sequence*](#nt:d-char-sequence "5.13.5String literals[lex.string]") shall consist of at most 16 characters[.](#lex.string-2.sentence-4)
[3](#lex.string-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1919)
[*Note [1](#lex.string-note-1)*:
The characters '(' and ')' can appear in a[*raw-string*](#nt:raw-string "5.13.5String literals[lex.string]")[.](#lex.string-3.sentence-1)
Thus, R"delimiter((a|b))delimiter" is equivalent to"(a|b)"[.](#lex.string-3.sentence-2)
— *end note*]
[4](#lex.string-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1926)
[*Note [2](#lex.string-note-2)*:
A source-file new-line in a raw string literal results in a new-line in the
resulting execution string literal[.](#lex.string-4.sentence-1)
Assuming no
whitespace at the beginning of lines in the following example, the assert will succeed:const char* p = R"(a\
b
c)";
assert(std::strcmp(p, "a\\\nb\nc") == 0);
— *end note*]
[5](#lex.string-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1939)
[*Example [1](#lex.string-example-1)*:
The raw stringR"a(
)\
a"
)a" is equivalent to "\n)\\\na\"\n"[.](#lex.string-5.sentence-1)
The raw stringR"(x = "\"y\"")" is equivalent to "x = \"\\\"y\\\"\""[.](#lex.string-5.sentence-2)
— *end example*]
[6](#lex.string-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1955)
Ordinary string literals and UTF-8 string literals are
also referred to as [*narrow string literals*](#def:literal,string,narrow "5.13.5String literals[lex.string]")[.](#lex.string-6.sentence-1)
[7](#lex.string-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1960)
The [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* in
any sequence of adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* shall have at most one unique [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") among them[.](#lex.string-7.sentence-1)
The common [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") of the sequence is
that [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]"), if any[.](#lex.string-7.sentence-2)
[*Note [3](#lex.string-note-3)*:
A [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s rawness has
no effect on the determination of the common [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#lex.string-7.sentence-3)
— *end note*]
[8](#lex.string-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L1972)
In translation phase 6 ([[lex.phases]](lex.phases "5.2Phases of translation")),
adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* are concatenated[.](#lex.string-8.sentence-1)
The lexical structure and grouping of
the contents of the individual [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* is retained[.](#lex.string-8.sentence-2)
[*Example [2](#lex.string-example-2)*:
"\xA" "B" represents
the code unit '\xA' and the character 'B' after concatenation
(and not the single code unit '\xAB')[.](#lex.string-8.sentence-3)
Similarly,R"(\u00)" "41" represents six characters,
starting with a backslash and ending with the digit 1 (and not the single character 'A' specified by a [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]"))[.](#lex.string-8.sentence-4)
Table [13](#tab:lex.string.concat "Table 13: String literal concatenations") has some examples of valid concatenations[.](#lex.string-8.sentence-5)
— *end example*]
Table [13](#tab:lex.string.concat) — String literal concatenations [[tab:lex.string.concat]](./tab:lex.string.concat)
| [🔗](#tab:lex.string.concat-row-1)<br>Source | | Means | Source | | Means | Source | | Means |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [🔗](#tab:lex.string.concat-row-2)<br>u"a" | u"b" | u"ab" | U"a" | U"b" | U"ab" | L"a" | L"b" | L"ab" |
| [🔗](#tab:lex.string.concat-row-3)<br>u"a" | "b" | u"ab" | U"a" | "b" | U"ab" | L"a" | "b" | L"ab" |
| [🔗](#tab:lex.string.concat-row-4)<br>"a" | u"b" | u"ab" | "a" | U"b" | U"ab" | "a" | L"b" | L"ab" |
[9](#lex.string-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2017)
Evaluating a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") results in a string literal object
with static storage duration ([[basic.stc]](basic.stc "6.8.6Storage duration"))[.](#lex.string-9.sentence-1)
[*Note [4](#lex.string-note-4)*:
String literal objects are potentially non-unique ([[intro.object]](intro.object "6.8.2Object model"))[.](#lex.string-9.sentence-2)
Whether successive evaluations of a[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") yield the same or a different object is
unspecified[.](#lex.string-9.sentence-3)
— *end note*]
[*Note [5](#lex.string-note-5)*:
The effect of attempting to modify a string literal object is undefined[.](#lex.string-9.sentence-4)
— *end note*]
[10](#lex.string-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2031)
String literal objects are initialized with
the sequence of code unit values
corresponding to the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s sequence of[*s-char*](#nt:s-char "5.13.5String literals[lex.string]")*s* (originally from non-raw string literals) and[*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s* (originally from raw string literals),
plus a terminating U+0000 null character,
in order as follows:
- [(10.1)](#lex.string-10.1)
The sequence of characters denoted by each contiguous sequence of[*basic-s-char*](#nt:basic-s-char "5.13.5String literals[lex.string]")*s*,[*r-char*](#nt:r-char "5.13.5String literals[lex.string]")*s*,[*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]")*s* ([[lex.ccon]](#lex.ccon "5.13.3Character literals")), and[*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")*s* ([[lex.charset]](lex.charset "5.3.1Character sets"))
is encoded to a code unit sequence
using the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s associated character encoding[.](#lex.string-10.1.sentence-1)
If a character lacks representation in the associated character encoding,
then the program is ill-formed[.](#lex.string-10.1.sentence-2)
[*Note [6](#lex.string-note-6)*:
No character lacks representation in any Unicode encoding form[.](#lex.string-10.1.sentence-3)
— *end note*]
When encoding a stateful character encoding,
implementations should encode the first such sequence
beginning with the initial encoding state and
encode subsequent sequences
beginning with the final encoding state of the prior sequence[.](#lex.string-10.1.sentence-4)
[*Note [7](#lex.string-note-7)*:
The encoded code unit sequence can differ from
the sequence of code units that would be obtained by
encoding each character independently[.](#lex.string-10.1.sentence-5)
— *end note*]
- [(10.2)](#lex.string-10.2)
Each [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](#lex.ccon "5.13.3Character literals"))
contributes a single code unit with a value as follows:
* [(10.2.1)](#lex.string-10.2.1)
Let v be the integer value represented by
the octal number comprising
the sequence of [*octal-digit*](#nt:octal-digit "5.13.2Integer literals[lex.icon]")*s* in
an [*octal-escape-sequence*](#nt:octal-escape-sequence "5.13.3Character literals[lex.ccon]") or by
the hexadecimal number comprising
the sequence of [*hexadecimal-digit*](#nt:hexadecimal-digit "5.13.2Integer literals[lex.icon]")*s* in
a [*hexadecimal-escape-sequence*](#nt:hexadecimal-escape-sequence "5.13.3Character literals[lex.ccon]")[.](#lex.string-10.2.1.sentence-1)
* [(10.2.2)](#lex.string-10.2.2)
If v does not exceed the range of representable values of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type,
then the value is v[.](#lex.string-10.2.2.sentence-1)
* [(10.2.3)](#lex.string-10.2.3)
Otherwise,
if the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]") is absent or L, andv does not exceed the range of representable values of
the corresponding unsigned type for the underlying type of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type,
then the value is the unique value of
the [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")'s array element type T that is congruent to v modulo 2N, where N is the width of T[.](#lex.string-10.2.3.sentence-1)
* [(10.2.4)](#lex.string-10.2.4)
Otherwise, the program is ill-formed[.](#lex.string-10.2.4.sentence-1)
When encoding a stateful character encoding,
these sequences should have no effect on encoding state[.](#lex.string-10.2.sentence-2)
- [(10.3)](#lex.string-10.3)
Each [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") ([[lex.ccon]](#lex.ccon "5.13.3Character literals"))
contributes animplementation-defined
code unit sequence[.](#lex.string-10.3.sentence-1)
When encoding a stateful character encoding,
it isimplementation-defined
what effect these sequences have on encoding state[.](#lex.string-10.3.sentence-2)
### [5.13.6](#lex.string.uneval) Unevaluated strings [[lex.string.uneval]](lex.string.uneval)
[unevaluated-string:](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]")
[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")
[1](#lex.string.uneval-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2114)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") shall have no [*encoding-prefix*](#nt:encoding-prefix "5.13.3Character literals[lex.ccon]")[.](#lex.string.uneval-1.sentence-1)
[2](#lex.string.uneval-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2117)
Each [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]") and each [*simple-escape-sequence*](#nt:simple-escape-sequence "5.13.3Character literals[lex.ccon]") in an [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") is
replaced by the member of the translation character set it denotes[.](#lex.string.uneval-2.sentence-1)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") that contains
a [*numeric-escape-sequence*](#nt:numeric-escape-sequence "5.13.3Character literals[lex.ccon]") or
a [*conditional-escape-sequence*](#nt:conditional-escape-sequence "5.13.3Character literals[lex.ccon]") is ill-formed[.](#lex.string.uneval-2.sentence-2)
[3](#lex.string.uneval-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2125)
An [*unevaluated-string*](#nt:unevaluated-string "5.13.6Unevaluated strings[lex.string.uneval]") is never evaluated and
its interpretation depends on the context in which it appears[.](#lex.string.uneval-3.sentence-1)
### [5.13.7](#lex.bool) Boolean literals [[lex.bool]](lex.bool)
[boolean-literal:](#nt:boolean-literal "5.13.7Boolean literals[lex.bool]")
false
true
[1](#lex.bool-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2138)
The Boolean literals are the keywords false and true[.](#lex.bool-1.sentence-1)
Such literals have type bool[.](#lex.bool-1.sentence-2)
### [5.13.8](#lex.nullptr) Pointer literals [[lex.nullptr]](lex.nullptr)
[pointer-literal:](#nt:pointer-literal "5.13.8Pointer literals[lex.nullptr]")
nullptr
[1](#lex.nullptr-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2151)
The pointer literal is the keyword nullptr[.](#lex.nullptr-1.sentence-1)
It has typestd::nullptr_t[.](#lex.nullptr-1.sentence-2)
[*Note [1](#lex.nullptr-note-1)*:
std::nullptr_t is a distinct type that is neither a pointer type nor a pointer-to-member type;
rather, a prvalue of this type is a null pointer constant and can be
converted to a null pointer value or null member pointer value[.](#lex.nullptr-1.sentence-3)
See [[conv.ptr]](conv.ptr "7.3.12Pointer conversions") and [[conv.mem]](conv.mem "7.3.13Pointer-to-member conversions")[.](#lex.nullptr-1.sentence-4)
— *end note*]
### [5.13.9](#lex.ext) User-defined literals [[lex.ext]](lex.ext)
[user-defined-literal:](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-integer-literal*](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-floating-point-literal*](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*user-defined-character-literal*](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[user-defined-integer-literal:](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]")
[*decimal-literal*](#nt:decimal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*octal-literal*](#nt:octal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-literal*](#nt:hexadecimal-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*binary-literal*](#nt:binary-literal "5.13.2Integer literals[lex.icon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-floating-point-literal:](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]")
[*fractional-constant*](#nt:fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]")opt [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*digit-sequence*](#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*exponent-part*](#nt:exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-fractional-constant*](#nt:hexadecimal-fractional-constant "5.13.4Floating-point literals[lex.fcon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*hexadecimal-prefix*](#nt:hexadecimal-prefix "5.13.2Integer literals[lex.icon]") [*hexadecimal-digit-sequence*](#nt:hexadecimal-digit-sequence "5.13.2Integer literals[lex.icon]") [*binary-exponent-part*](#nt:binary-exponent-part "5.13.4Floating-point literals[lex.fcon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-string-literal:](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")
[*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[user-defined-character-literal:](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]")
[*character-literal*](#nt:character-literal "5.13.3Character literals[lex.ccon]") [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[ud-suffix:](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")
[*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]")
[1](#lex.ext-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2203)
If a token matches both [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") and another [*literal*](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]") kind, it
is treated as the latter[.](#lex.ext-1.sentence-1)
[*Example [1](#lex.ext-example-1)*:
123_km is a [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]"), but 12LL is an[*integer-literal*](#nt:integer-literal "5.13.2Integer literals[lex.icon]")[.](#lex.ext-1.sentence-2)
— *end example*]
The syntactic non-terminal preceding the [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") in a[*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") is taken to be the longest sequence of
characters that could match that non-terminal[.](#lex.ext-1.sentence-3)
[2](#lex.ext-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2215)
A [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") is treated as a call to a literal operator or
literal operator template ([[over.literal]](over.literal "12.6User-defined literals"))[.](#lex.ext-2.sentence-1)
To determine the form of this call for
a given [*user-defined-literal*](#nt:user-defined-literal "5.13.9User-defined literals[lex.ext]") *L* with [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") *X*,
first let *S* be the set of declarations
found by unqualified lookup for the [*literal-operator-id*](over.literal#nt:literal-operator-id "12.6User-defined literals[over.literal]") whose literal suffix identifier is *X* ([[basic.lookup.unqual]](basic.lookup.unqual "6.5.3Unqualified name lookup"))[.](#lex.ext-2.sentence-2)
*S* shall not be empty[.](#lex.ext-2.sentence-3)
[3](#lex.ext-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2226)
If *L* is a [*user-defined-integer-literal*](#nt:user-defined-integer-literal "5.13.9User-defined literals[lex.ext]"), let *n* be the literal
without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#lex.ext-3.sentence-1)
If *S* contains a literal operator with
parameter type unsigned long long, the literal *L* is treated as a call of
the formoperator ""*X*(*n*ULL)
Otherwise, *S* shall contain a raw literal operator
or a numeric literal operator template ([[over.literal]](over.literal "12.6User-defined literals")) but not both[.](#lex.ext-3.sentence-3)
If *S* contains a raw literal operator,
the literal *L* is treated as a call of the formoperator ""*X*("*n*")
Otherwise (*S* contains a numeric literal operator template),*L* is treated as a call of the formoperator ""*X*<'c1', 'c2', ... 'ck'>() where *n* is the source character sequence c1c2...ck[.](#lex.ext-3.sentence-5)
[*Note [1](#lex.ext-note-1)*:
The sequencec1c2...ck can only contain characters from the basic character set[.](#lex.ext-3.sentence-6)
— *end note*]
[4](#lex.ext-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2252)
If *L* is a [*user-defined-floating-point-literal*](#nt:user-defined-floating-point-literal "5.13.9User-defined literals[lex.ext]"), let *f* be the
literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#lex.ext-4.sentence-1)
If *S* contains a literal operator
with parameter type long double, the literal *L* is treated as a call of
the formoperator ""*X*(*f*L)
Otherwise, *S* shall contain a raw literal operator
or a numeric literal operator template ([[over.literal]](over.literal "12.6User-defined literals")) but not both[.](#lex.ext-4.sentence-3)
If *S* contains a raw literal operator,
the [*literal*](#nt:literal "5.13.1Kinds of literals[lex.literal.kinds]") *L* is treated as a call of the formoperator ""*X*("*f*")
Otherwise (*S* contains a numeric literal operator template),*L* is treated as a call of the formoperator ""*X*<'c1', 'c2', ... 'ck'>() where *f* is the source character sequence c1c2...ck[.](#lex.ext-4.sentence-5)
[*Note [2](#lex.ext-note-2)*:
The sequencec1c2...ck can only contain characters from the basic character set[.](#lex.ext-4.sentence-6)
— *end note*]
[5](#lex.ext-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2278)
If *L* is a [*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]"),
let *str* be the literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") and let *len* be the number of code units in *str* (i.e., its length excluding the terminating null character)[.](#lex.ext-5.sentence-1)
If *S* contains a literal operator template with
a constant template parameter for which *str* is
a well-formed [*template-argument*](temp.names#nt:template-argument "13.3Names of template specializations[temp.names]"),
the literal *L* is treated as a call of the formoperator ""*X*<*str*>()
Otherwise, the literal *L* is treated as a call of the formoperator ""*X*(*str*, *len*)
[6](#lex.ext-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2295)
If *L* is a [*user-defined-character-literal*](#nt:user-defined-character-literal "5.13.9User-defined literals[lex.ext]"), let *ch* be the
literal without its [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")[.](#lex.ext-6.sentence-1)
*S* shall contain a [literal operator](over.literal#def:literal,operator "12.6User-defined literals[over.literal]") whose only parameter has
the type of *ch* and the
literal *L* is treated as a call
of the formoperator ""*X*(*ch*)
[7](#lex.ext-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2306)
[*Example [2](#lex.ext-example-2)*: long double operator ""_w(long double);
std::string operator ""_w(const char16_t*, std::size_t);unsigned operator ""_w(const char*);int main() {1.2_w; // calls operator ""_w(1.2L)u"one"_w; // calls operator ""_w(u"one", 3)12_w; // calls operator ""_w("12")"two"_w; // error: no applicable literal operator} — *end example*]
[8](#lex.ext-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2321)
In translation phase 6 ([[lex.phases]](lex.phases "5.2Phases of translation")), adjacent [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* are concatenated and[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")*s* are considered [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]")*s* for that
purpose[.](#lex.ext-8.sentence-1)
During concatenation, [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")es are removed and ignored and
the concatenation process occurs as described in [[lex.string]](#lex.string "5.13.5String literals")[.](#lex.ext-8.sentence-2)
At the end of phase
6, if a [*string-literal*](#nt:string-literal "5.13.5String literals[lex.string]") is the result of a concatenation involving at least one[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]"), all the participating[*user-defined-string-literal*](#nt:user-defined-string-literal "5.13.9User-defined literals[lex.ext]")*s* shall have the same [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") and that suffix is applied to the result of the concatenation[.](#lex.ext-8.sentence-3)
[9](#lex.ext-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lex.tex#L2331)
[*Example [3](#lex.ext-example-3)*: int main() {L"A" "B" "C"_x; // OK, same as L"ABC"_x"P"_x "Q" "R"_y; // error: two different [*ud-suffix*](#nt:ud-suffix "5.13.9User-defined literals[lex.ext]")es} — *end example*]