Стандарт C++ 11 (1119564), страница 12
Текст из файла (страница 12)
— end note ]:Table 4 — Keywordsalignasalignofasmautoboolbreakcasecatchcharchar16_tchar32_tclassconstconstexprconst_castcontinuedecltypedefaultdeletedodoubledynamic_castelseenumexplicitexportexternfalsefloatforfriendgotoifinlineintlongmutablenamespacenewnoexceptnullptroperatorprivateprotectedpublicregisterreinterpret_castreturnshortsignedsizeofstaticstatic_assertstatic_caststructswitchtemplatethisthread_localthrowtruetrytypedeftypeidtypenameunionunsignedusingvirtualvoidvolatilewchar_twhile20) On systems in which linkers cannot accept extended characters, an encoding of the universal-character-name may be usedin forming valid external identifiers.
For example, some otherwise unused character or sequence of characters may be used toencode the \u in a universal-character-name. Extended characters may produce a long external identifier, but C++ does notplace a translation limit on significant characters for external identifiers. In C++, upper- and lower-case letters are considereddifferent for all identifiers, including external identifiers.§ 2.12© ISO/IEC 2011 – All rights reserved23ISO/IEC 14882:2011(E)2Furthermore, the alternative representations shown in Table 5 for certain operators and punctuators (2.6)are reserved and shall not be used otherwise:Table 5 — Alternative representationsandnot_eq2.131and_eqorbitandor_eqbitorxorcomplxor_eqnotOperators and punctuators[lex.operators]The lexical representation of C++ programs includes a number of preprocessing tokens which are used inthe syntax of the preprocessor or are converted into tokens for operators and punctuators:preprocessing-op-or-punc: one{}[<::><%new delete?+*!=<ˆ=&=|=<=>=&&and and_eqbitandoror_eqxorof]%>::/><<||bitorxor_eq#%:.%+=>>++compl##%:%:.*ˆ-=>>=-not(;):&*=<<=,not_eq|/===->*...~%=!=->Each preprocessing-op-or-punc is converted to a single token in translation phase 7 (2.2).2.14Literals2.14.11Kinds of literals[lex.literal][lex.literal.kinds]There are several kinds of literals.21literal:integer-literalcharacter-literalfloating-literalstring-literalboolean-literalpointer-literaluser-defined-literal2.14.2Integer literals[lex.icon]integer-literal:decimal-literal integer-suffixoptoctal-literal integer-suffixopthexadecimal-literal integer-suffixoptdecimal-literal:nonzero-digitdecimal-literal digitoctal-literal:0octal-literal octal-digit21) The term “literal” generally designates, in this International Standard, those tokens that are called “constants” in ISO C.§ 2.14.224© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)hexadecimal-literal:0x hexadecimal-digit0X hexadecimal-digithexadecimal-literal hexadecimal-digitnonzero-digit: one of1 2 3 4 5 6 7 8 9octal-digit: one of0 1 2 3 4 5 6 7hexadecimal-digit: one of0 1 2 3 4 5 6 7 8 9a b c d e fA B C D E Finteger-suffix:unsigned-suffix long-suffixoptunsigned-suffix long-long-suffixoptlong-suffix unsigned-suffixoptlong-long-suffix unsigned-suffixoptunsigned-suffix: one ofu Ulong-suffix: one ofl Llong-long-suffix: one ofll LL1An integer literal is a sequence of digits that has no period or exponent part.
An integer literal may havea prefix that specifies its base and a suffix that specifies its type. The lexically first digit of the sequenceof digits is the most significant. A decimal integer literal (base ten) begins with a digit other than 0 andconsists of a sequence of decimal digits. An octal integer literal (base eight) begins with the digit 0 andconsists of a sequence of octal digits.22 A hexadecimal integer literal (base sixteen) begins with 0x or 0X andconsists of a sequence of hexadecimal digits, which include the decimal digits and the letters a through fand A through F with decimal values ten through fifteen. [ Example: the number twelve can be written 12,014, or 0XC. — end example ]2The type of an integer literal is the first of the corresponding list in Table 6 in which its value can berepresented.Table 6 — Types of integer constantsSuffixnoneDecimal constantsintlong intlong long intu or Uunsigned intunsigned long intunsigned long long intlong intlong long intl or LOctal or hexadecimal constantintunsigned intlong intunsigned long intlong long intunsigned long long intunsigned intunsigned long intunsigned long long intlong intunsigned long intlong long intunsigned long long int22) The digits 8 and 9 are not octal digits.§ 2.14.2© ISO/IEC 2011 – All rights reserved25ISO/IEC 14882:2011(E)Table 6 — Types of integer constants (continued)3SuffixBoth u or Uand l or Lll or LLDecimal constantsunsigned long intunsigned long long intlong long intBoth u or Uand ll or LLunsigned long long intOctal or hexadecimal constantunsigned long intunsigned long long intlong long intunsigned long long intunsigned long long intIf an integer literal cannot be represented by any type in its list and an extended integer type (3.9.1) canrepresent its value, it may have that extended integer type.
If all of the types in the list for the literal aresigned, the extended integer type shall be signed. If all of the types in the list for the literal are unsigned, theextended integer type shall be unsigned. If the list contains both signed and unsigned types, the extendedinteger type may be signed or unsigned. A program is ill-formed if one of its translation units contains aninteger literal that cannot be represented by any of the allowed types.2.14.3Character literals[lex.ccon]character-literal:’ c-char-sequence ’u’ c-char-sequence ’U’ c-char-sequence ’L’ c-char-sequence ’c-char-sequence:c-charc-char-sequence c-charc-char:any member of the source character set exceptthe single-quote ’, backslash \, or new-line characterescape-sequenceuniversal-character-nameescape-sequence:simple-escape-sequenceoctal-escape-sequencehexadecimal-escape-sequencesimple-escape-sequence: one of\’ \" \?\\\a \b \f \n \r\t\voctal-escape-sequence:\ octal-digit\ octal-digit octal-digit\ octal-digit octal-digit octal-digithexadecimal-escape-sequence:\x hexadecimal-digithexadecimal-escape-sequence hexadecimal-digit1A character literal is one or more characters enclosed in single quotes, as in ’x’, optionally preceded byone of the letters u, U, or L, as in u’y’, U’z’, or L’x’, respectively.
A character literal that does not beginwith u, U, or L is an ordinary character literal, also referred to as a narrow-character literal. An ordinarycharacter literal that contains a single c-char has type char, with value equal to the numerical value of the§ 2.14.326© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)encoding of the c-char in the execution character set. An ordinary character literal that contains more thanone c-char is a multicharacter literal. A multicharacter literal has type int and implementation-definedvalue.2A character literal that begins with the letter u, such as u’y’, is a character literal of type char16_t.
Thevalue of a char16_t literal containing a single c-char is equal to its ISO 10646 code point value, provided thatthe code point is representable with a single 16-bit code unit. (That is, provided it is a basic multi-lingualplane code point.) If the value is not representable within 16 bits, the program is ill-formed. A char16_tliteral containing multiple c-chars is ill-formed.
A character literal that begins with the letter U, such asU’z’, is a character literal of type char32_t. The value of a char32_t literal containing a single c-char isequal to its ISO 10646 code point value. A char32_t literal containing multiple c-chars is ill-formed. Acharacter literal that begins with the letter L, such as L’x’, is a wide-character literal. A wide-characterliteral has type wchar_t.23 The value of a wide-character literal containing a single c-char has value equalto the numerical value of the encoding of the c-char in the execution wide-character set, unless the c-charhas no representation in the execution wide-character set, in which case the value is implementation-defined.[ Note: The type wchar_t is able to represent all members of the execution wide-character set (see 3.9.1).— end note ].
The value of a wide-character literal containing multiple c-chars is implementation-defined.3Certain nongraphic characters, the single quote ’, the double quote ", the question mark ?,24 and thebackslash \, can be represented according to Table 7. The double quote " and the question mark ?, canbe represented as themselves or by the escape sequences \" and \? respectively, but the single quote ’and the backslash \ shall be represented by the escape sequences \’ and \\ respectively. Escape sequencesin which the character following the backslash is not listed in Table 7 are conditionally-supported, withimplementation-defined semantics. An escape sequence specifies a single character.Table 7 — Escape sequencesnew-linehorizontal tabvertical tabbackspacecarriage returnform feedalertbackslashquestion marksingle quotedouble quoteoctal numberhex number4NL(LF)HTVTBSCRFFBEL\?’"ooohhh\n\t\v\b\r\f\a\\\?\’\"\ooo\xhhhThe escape \ooo consists of the backslash followed by one, two, or three octal digits that are taken to specifythe value of the desired character.