integer-literal: binary-literal integer-suffix octal-literal integer-suffix decimal-literal integer-suffix hexadecimal-literal integer-suffix
binary-literal: 0b binary-digit 0B binary-digit binary-literal ' binary-digit
octal-literal: 0 octal-literal ' octal-digit
decimal-literal: nonzero-digit decimal-literal ' digit
hexadecimal-literal: hexadecimal-prefix hexadecimal-digit-sequence
binary-digit: 0 1
octal-digit: one of 0 1 2 3 4 5 6 7
nonzero-digit: one of 1 2 3 4 5 6 7 8 9
hexadecimal-prefix: one of 0x 0X
hexadecimal-digit-sequence: hexadecimal-digit hexadecimal-digit-sequence ' hexadecimal-digit
hexadecimal-digit: 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: unsigned-suffix long-suffix unsigned-suffix long-long-suffix long-suffix unsigned-suffix long-long-suffix unsigned-suffix
unsigned-suffix: one of u U
long-suffix: one of l L
long-long-suffix: one of ll LL
Suffix | Decimal literal | Binary, octal, or hexadecimal literal |
none | int | int |
long int | unsigned int | |
long long int | long int | |
unsigned long int | ||
long long int | ||
unsigned long long int | ||
u or U | unsigned int | unsigned int |
unsigned long int | unsigned long int | |
unsigned long long int | unsigned long long int | |
l or L | long int | long int |
long long int | unsigned long int | |
long long int | ||
unsigned long long int | ||
Both u or U | unsigned long int | unsigned long int |
and l or L | unsigned long long int | unsigned long long int |
ll or LL | long long int | long long int |
unsigned long long int | ||
Both u or U | unsigned long long int | unsigned long long int |
and ll or LL |
character-literal: encoding-prefix ' c-char-sequence '
encoding-prefix: one of u8 u U L
c-char-sequence: c-char c-char-sequence c-char
c-char: any member of the source character set except the single-quote ', backslash \, or new-line character escape-sequence universal-character-name
escape-sequence: simple-escape-sequence octal-escape-sequence hexadecimal-escape-sequence
simple-escape-sequence: one of \' \" \? \\ \a \b \f \n \r \t \v
octal-escape-sequence: \ octal-digit \ octal-digit octal-digit \ octal-digit octal-digit octal-digit
hexadecimal-escape-sequence: \x hexadecimal-digit hexadecimal-escape-sequence hexadecimal-digit
new-line | NL(LF) | \n |
horizontal tab | HT | \t |
vertical tab | VT | \v |
backspace | BS | \b |
carriage return | CR | \r |
form feed | FF | \f |
alert | BEL | \a |
backslash | \ | \\ |
question mark | ? | \? |
single quote | ' | \' |
double quote | " | \" |
octal number | ooo | \ooo |
hex number | hhh | \xhhh |
floating-literal: decimal-floating-literal hexadecimal-floating-literal
decimal-floating-literal: fractional-constant exponent-part floating-suffix digit-sequence exponent-part floating-suffix
hexadecimal-floating-literal: hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part floating-suffix hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-suffix
fractional-constant: digit-sequence . digit-sequence digit-sequence .
hexadecimal-fractional-constant: hexadecimal-digit-sequence . hexadecimal-digit-sequence hexadecimal-digit-sequence .
exponent-part: e sign digit-sequence E sign digit-sequence
binary-exponent-part: p sign digit-sequence P sign digit-sequence
sign: one of + -
digit-sequence: digit digit-sequence ' digit
floating-suffix: one of f l F L
string-literal: encoding-prefix " s-char-sequence " encoding-prefix R raw-string
s-char-sequence: s-char s-char-sequence s-char
s-char: any member of the source character set except the double-quote ", backslash \, or new-line character escape-sequence universal-character-name
raw-string: " d-char-sequence ( r-char-sequence ) d-char-sequence "
r-char-sequence: r-char r-char-sequence r-char
r-char: any member of the source character set, except a right parenthesis ) followed by the initial d-char-sequence (which may be empty) followed by a double quote ".
d-char-sequence: d-char d-char-sequence d-char
d-char: any member of the basic source character set except: space, the left parenthesis (, the right parenthesis ), the backslash \, and the control characters representing horizontal tab, vertical tab, form feed, and newline.
const char* p = R"(a\ b c)"; assert(std::strcmp(p, "a\\\nb\nc") == 0);
boolean-literal: false true
pointer-literal: nullptr
user-defined-literal: user-defined-integer-literal user-defined-floating-literal user-defined-string-literal user-defined-character-literal
user-defined-integer-literal: decimal-literal ud-suffix octal-literal ud-suffix hexadecimal-literal ud-suffix binary-literal ud-suffix
user-defined-floating-literal: fractional-constant exponent-part ud-suffix digit-sequence exponent-part ud-suffix hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part ud-suffix hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part ud-suffix
user-defined-string-literal: string-literal ud-suffix
user-defined-character-literal: character-literal ud-suffix
ud-suffix: identifier
operator "" X(nULL)
operator "" X("n")
operator "" X<'', '', ... ''>()
operator "" X(fL)
operator "" X("f")
operator "" X<'', '', ... ''>()
operator "" X(str, len)
operator "" X(ch)
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 }