Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
825 lines (825 sloc) 32.2 KB
Annex A (informative)
Grammar summary [gram]
1 This summary of C++ syntax is intended to be an aid to comprehension. It is not an exact statement of the language. In particular, the grammar described here accepts a superset of valid C++ constructs. Disambiguation rules (6.8, 7.1, 10.2) must be applied to distinguish expressions from declarations. Further, access control, ambiguity, and type rules must be used to weed out syntactically valid but meaningless constructs.
A.1 Keywords [gram.key]
1 New context-dependent keywords are introduced into a program by typedef (7.1.3), namespace (7.3.1), class (clause 9), enumeration (7.2), and template (clause 14) declarations.
typedef-name: identifier
namespace-name: original-namespace-name namespace-alias
original-namespace-name: identifier
namespace-alias: identifier
class-name: identifier
template-id enum-name:
identifier
template-name: identifier
Note that a typedef-name naming a class is also a class-name (9.1).
A.2
Lexical conventions [gram.lex]
§ A.2
1224
hex-quad:
hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
universal-character-name: \u hex-quad
\U hex-quad hex-quad
⃝c ISO/IEC N2798=08-0308
preprocessing-token: header-name
identifier
pp-number
character-literal
user-defined-character-literal
string-literal
user-defined-string-literal
preprocessing-op-or-punc
each non-white-space character that cannot be one of the above
token: identifier
keyword literal operator punctuator
header-name:
< h-char-sequence >
" q-char-sequence "
h-char-sequence: h-char
h-char-sequence h-char h-char:
any member of the source character set except new-line and >
q-char-sequence: q-char
q-char-sequence q-char q-char:
any member of the source character set except new-line and "
pp-number: digit
. digit
pp-number digit
pp-number identifier-nondigit pp-number e sign
pp-number E sign
pp-number .
identifier: identifier-nondigit
identifier identifier-nondigit identifier digit
identifier-nondigit: nondigit
universal-character-name
other implementation-defined characters
nondigit: one of abcdefghijklm nopqrstuvwxyz ABCDEFGHIJKLM NOPQRSTUVWXYZ_
§ A.2
1225
⃝c ISO/IEC digit: one of
N2798=08-0308
0123456789
preprocessing-op-or-punc: one of
{ } [ ]
<::><%%>
new delete ? :: +-*/%ˆ&|∼
! = <
ˆ= &= |=
<= >= &&
and and_eq bitand or or_eq xor
literal: integer-literal
character-literal floating-literal string-literal boolean-literal pointer-literal user-defined-literal
> += -= *= /= %= << >> >>= <<= == != || ++ -- , ->* ->
# ## ( ) %:%:%:;:... ..*
bitor compl not xor_eq
not_eq
§ A.2
1226
integer-literal:
decimal-literal integer-suffixopt octal-literal integer-suffixopt hexadecimal-literal integer-suffixopt
decimal-literal: nonzero-digit
decimal-literal digit
octal-literal:
0
octal-literal octal-digit
hexadecimal-literal:
0x hexadecimal-digit
0X hexadecimal-digit hexadecimal-literal hexadecimal-digit
nonzero-digit: one of 123456789
octal-digit: one of 01234567
hexadecimal-digit: one of 0123456789
abcdef ABCDEF
integer-suffix:
unsigned-suffix long-suffixopt unsigned-suffix long-long-suffixopt long-suffix unsigned-suffixopt long-long-suffix unsigned-suffixopt
unsigned-suffix: one of uU
long-suffix: one of lL
⃝c ISO/IEC N2798=08-0308 long-long-suffix: one of
§ A.2
1227
ll LL
character-literal:
’ c-char-sequence ’
u’ c-char-sequence ’ U’ c-char-sequence ’ L’ c-char-sequence ’
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
floating-literal:
fractional-constant exponent-partopt floating-suffixopt digit-sequence exponent-part floating-suffixopt
fractional-constant:
digit-sequenceopt . digit-sequence digit-sequence .
exponent-part:
e signopt digit-sequence
E signopt digit-sequence sign: one of
+-
digit-sequence: digit
digit-sequence digit
floating-suffix: one of flFL
⃝c ISO/IEC N2798=08-0308
§ A.2
1228
string-literal:
" s-char-sequenceopt "
u8" s-char-sequenceopt " u" s-char-sequenceopt " U" s-char-sequenceopt " L" s-char-sequenceopt " R raw-string
u8R raw-string uR raw-string UR raw-string LR 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-sequenceopt [ r-char-sequenceopt ] d-char-sequenceopt "
r-char-sequence: r-char
r-char-sequence r-char
r-char:
any member of the source character set, except
(1), a backslash \followed by a u or U, or
(2), a right square bracket ] followed by the initial d-char-sequence (which may be empty) followed by a double quote ".
universal-character-name
d-char-sequence: d-char
d-char-sequence d-char
d-char:
any member of the basic source character set except:
space, the left square bracket [, the right square bracket ], and the control characters representing horizontal tab, vertical tab, form feed, and newline.
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
⃝c ISO/IEC
N2798=08-0308
A.3
user-defined-integer-literal: decimal-literal ud-suffix
octal-literal ud-suffix hexadecimal-literal ud-suffix
user-defined-floating-literal:
fractional-constant exponent-partopt ud-suffix digit-sequence exponent-part ud-suffix
user-defined-string-literal: string-literal ud-suffix
user-defined-character-literal: character-literal ud-suffix
ud-suffix: identifier
Basic concepts
translation-unit: declaration-seqopt
[gram.basic]
[gram.expr]
A.4 Expressions
primary-expression: literal
this
( expression ) id-expression lambda-expression
id-expression: unqualified-id
qualified-id unqualified-id:
identifier operator-function-id conversion-function-id literal-operator-id
∼ class-name template-id
qualified-id:
::opt nested-name-specifier templateopt unqualified-id :: identifier
:: operator-function-id
:: template-id
nested-name-specifier: type-name ::
namespace-name ::
nested-name-specifier identifier ::
nested-name-specifier templateopt simple-template-id :: nested-name-specifieropt concept-id ::
lambda-expression:
lambda-introducer lambda-parameter-declarationopt compound-statement
lambda-introducer:
[ lambda-captureopt ]
§ A.4
1229
⃝c ISO/IEC N2798=08-0308
lambda-capture: capture-default
capture-list
capture-default , capture-list
capture-default:
& =
capture-list: capture
capture-list , capture
capture: identifier
& identifier this
lambda-parameter-declaration:
( lambda-parameter-declaration-listopt ) mutableopt attribute-specifieropt
exception-specificationopt lambda-return-type-clauseopt
lambda-parameter-declaration-list: lambda-parameter
lambda-parameter , lambda-parameter-declaration-list lambda-parameter:
decl-specifier-seq attribute-specifieropt lambda-return-type-clause:
-> attribute-specifieropt type-id
postfix-expression: primary-expression
declarator
§ A.4
1230
postfix-expression [ expression ] postfix-expression [ braced-init-list ] postfix-expression ( expression-listopt ) simple-type-specifier ( expression-listopt ) typename-specifier ( expression-listopt ) simple-type-specifier braced-init-list typename-specifier braced-init-list postfix-expression . templateopt id-expression postfix-expression -> templateopt id-expression postfix-expression . pseudo-destructor-name postfix-expression -> pseudo-destructor-name postfix-expression ++
postfix-expression --
dynamic_cast < type-id > ( expression ) static_cast < type-id > ( expression ) reinterpret_cast < type-id > ( expression ) const_cast < type-id > ( expression ) typeid ( expression )
typeid ( type-id )
expression-list: initializer-list
pseudo-destructor-name:
::opt nested-name-specifieropt
::opt nested-name-specifier template simple-template-id :: ∼ type-name ::opt nested-name-specifieropt ∼ type-name
type-name :: ∼ type-name
⃝c ISO/IEC N2798=08-0308
unary-expression: postfix-expression
++ cast-expression
-- cast-expression unary-operator cast-expression sizeof unary-expression sizeof ( type-id )
sizeof ... ( identifier ) alignof ( type-id ) new-expression delete-expression
unary-operator: one of *&+-!∼
new-expression:
::opt new new-placementopt new-type-id new-initializeropt ::opt new new-placementopt ( type-id ) new-initializeropt
new-placement:
( expression-list )
new-type-id:
type-specifier-seq new-declaratoropt
new-declarator:
ptr-operator new-declaratoropt directnoptr-new-declarator
directnoptr-new-declarator: [ expression ]
directnoptr-new-declarator [ constant-expression ]
new-initializer:
( expression-listopt )
braced-init-list
delete-expression:
::opt delete cast-expression ::opt delete [ ] cast-expression
cast-expression: unary-expression
( type-id ) cast-expression
pm-expression: cast-expression
pm-expression .* cast-expression pm-expression ->* cast-expression
multiplicative-expression: pm-expression
multiplicative-expression * pm-expression multiplicative-expression / pm-expression multiplicative-expression % pm-expression
additive-expression: multiplicative-expression
additive-expression + multiplicative-expression additive-expression - multiplicative-expression
§ A.4
1231
⃝c ISO/IEC N2798=08-0308
§ A.4
1232
shift-expression: additive-expression
shift-expression << additive-expression shift-expression >> additive-expression
relational-expression: shift-expression
relational-expression relational-expression relational-expression relational-expression
equality-expression: relational-expression
< shift-expression > shift-expression <= shift-expression >= shift-expression
equality-expression == relational-expression equality-expression != relational-expression
and-expression: equality-expression
and-expression & equality-expression
exclusive-or-expression: and-expression
exclusive-or-expression ˆ and-expression
inclusive-or-expression: exclusive-or-expression
inclusive-or-expression | exclusive-or-expression
logical-and-expression: inclusive-or-expression
logical-and-expression && inclusive-or-expression
logical-or-expression: logical-and-expression
logical-or-expression || logical-and-expression
conditional-expression: logical-or-expression
logical-or-expression ? expression : assignment-expression
assignment-expression: conditional-expression
logical-or-expression assignment-operator initializer-clause throw-expression
assignment-operator: one of
= *= /= %= += -= >>= <<= &= ˆ= |=
expression: assignment-expression
expression , assignment-expression
constant-expression: conditional-expression
⃝c ISO/IEC
A.5 Statements
N2798=08-0308
[gram.stmt]
statement: labeled-statement
attribute-specifieropt attribute-specifieropt attribute-specifieropt attribute-specifieropt attribute-specifieropt declaration-statement attribute-specifieropt late-checked-block
labeled-statement:
attribute-specifieropt attribute-specifieropt attribute-specifieropt
expression-statement: expressionopt ;
compound-statement:
{ statement-seqopt }
statement-seq: statement
expression-statement compound-statement selection-statement iteration-statement jump-statement
try-block
identifier : statement
case constant-expression : statement default : statement
statement-seq statement
selection-statement:
if ( condition ) statement
if ( condition ) statement else statement switch ( condition ) statement
condition: expression
type-specifier-seq attribute-specifieropt type-specifier-seq attribute-specifieropt
declarator = initializer-clause declarator braced-init-list
iteration-statement:
while ( condition ) statement
do statement while ( expression ) ;
for ( for-init-statement conditionopt ; expressionopt ) statement for ( for-range-declaration : expression ) statement
for-init-statement: expression-statement
simple-declaration for-range-declaration:
type-specifier-seq attribute-specifieropt declarator
jump-statement:
break ;
continue ;
return expressionopt ; return braced-init-list ; goto identifier ;
declaration-statement: block-declaration
late-checked-block:
late_check compound-statement
§ A.5
1233
⃝c ISO/IEC
A.6 Declarations
N2798=08-0308
[gram.dcl]
declaration-seq: declaration
declaration-seq declaration
declaration: block-declaration
function-definition template-declaration explicit-instantiation explicit-specialization linkage-specification namespace-definition concept-definition concept-map-definition attribute-declaration
block-declaration: simple-declaration
asm-definition namespace-alias-definition using-declaration using-directive static_assert-declaration alias-declaration opaque-enum-declaration
alias-declaration:
using identifier = type-id ;
simple-declaration:
attribute-specifieropt decl-specifier-seqopt attribute-specifieropt init-declarator-listopt ;
static_assert-declaration:
static_assert ( constant-expression , string-literal ) ;
attribute-declaration: attribute-specifier ;
decl-specifier: storage-class-specifier
type-specifier function-specifier friend
typedef constexpr alignment-specifier
decl-specifier-seq:
decl-specifier-seqopt decl-specifier
storage-class-specifier:
register
static
thread_local
extern
mutable
§ A.6
1234
⃝c ISO/IEC N2798=08-0308
function-specifier:
inline
virtual
explicit
typedef-name: identifier
type-specifier: simple-type-specifier
class-specifier enum-specifier elaborated-type-specifier typename-specifier cv-qualifier
type-specifier-seq:
type-specifier type-specifier-seqopt
simple-type-specifier:
::opt nested-name-specifieropt type-name
::opt nested-name-specifier template simple-template-id char
char16_t
char32_t
wchar_t
bool
short
int
long
signed
unsigned
float
double
void
auto
decltype ( expression )
type-name: class-name
enum-name typedef-name
elaborated-type-specifier:
class-key ::opt nested-name-specifieropt identifier
class-key ::opt nested-name-specifieropt templateopt simple-template-id
enum-key enum ::opt enum-name:
identifier
enum-specifier:
enum-key identifieropt
enum-key identifieropt
enum-head { enumerator-listopt }
enum-head { enumerator-list , }
nested-name-specifieropt identifier
enum-baseopt enum-baseopt
{ enumerator-listopt } { enumerator-list , }
enum-head:
enum-key identifieropt attribute-specifieropt enum-baseopt attribute-specifieropt
enum-key nested-name-specifier identifier
attribute-specifieropt enum-baseopt attribute-specifieropt
§ A.6
1235
⃝c ISO/IEC opaque-enum-declaration:
enum-key identifier attribute-specifieropt
enum-key:
enum
enum class
enum struct
enum-base:
: type-specifier-seq
enumerator-list: enumerator-definition
enumerator-list , enumerator-definition
enumerator-definition: enumerator
enumerator = constant-expression
enumerator: identifier
namespace-name: original-namespace-name namespace-alias
original-namespace-name: identifier
namespace-definition: named-namespace-definition unnamed-namespace-definition
named-namespace-definition: original-namespace-definition extension-namespace-definition
N2798=08-0308
enum-baseopt
attribute-specifieropt ;
original-namespace-definition:
inlineopt namespace identifier { namespace-body }
extension-namespace-definition:
inlineopt namespace original-namespace-name { namespace-body }
unnamed-namespace-definition:
inlineopt namespace { namespace-body }
namespace-body: declaration-seqopt
namespace-alias: identifier
namespace-alias-definition:
namespace identifier = qualified-namespace-specifier ;
qualified-namespace-specifier:
::opt nested-name-specifieropt namespace-name
using-declaration:
using typenameopt ::opt nested-name-specifier unqualified-id ; using :: unqualified-id ;
using ::opt using ::opt using ::opt
using-directive:
nested-name-specifieropt nested-name-specifieropt nested-name-specifieropt
concept_map ::opt nested-name-specifieropt concept_map ::opt nested-name-specifieropt concept-name ;
concept-id ; concept-nameopt ;
attribute-specifieropt using namespace ::opt
asm-definition:
asm ( string-literal ) ;
nested-name-specifieropt namespace-name ;
§ A.6
1236
⃝c ISO/IEC
N2798=08-0308
linkage-specification:
extern string-literal { declaration-seqopt } extern string-literal declaration
attribute-specifier:
[ [ attribute-list ] ]
attribute-list: attributeopt
attribute-list , attributeopt attribute:
attribute-token attribute-argument-clauseopt
attribute-token: identifier
attribute-scoped-token attribute-scoped-token:
attribute-namespace :: identifier attribute-namespace:
identifier attribute-argument-clause:
( balanced-token-seq )
balanced-token-seq: balanced-token
balanced-token-seq balanced-token
balanced-token:
( balanced-token-seq )
[ balanced-token-seq ]
{ balanced-token-seq }
any token other than a parenthesis, a bracket, or a brace
alignment-specifier:
alignas ( constant-expression ) alignas ( type-id )
A.7 Declarators
[gram.decl]
init-declarator-list: init-declarator
init-declarator-list , init-declarator init-declarator:
declarator initializeropt
declarator:
direct-declarator
ptr-operator declarator
ptr-declarator
noptr-declarator parameters-and-qualifiers -> attribute-specifieropt
ptr-declarator: noptr-declarator
ptr-operator ptr-declarator
type-id
§ A.7
1237
⃝c ISO/IEC
N2798=08-0308
direct-declarator noptr-declarator: declarator-id attribute-specifieropt
direct-declarator (
cv-qualifier-seqopt
direct-declarator (
cv-qualifier-seqopt
direct-declarator [
noptr-declarator parameters-and-qualifiers
parameter-declaration-clause ) ref-qualifieropt exception-specificationopt parameter-declaration-clause ) ref-qualifieropt exception-specificationopt constant-expressionopt ]
-> type-id
noptr-declarator [ constant-expressionopt ] attribute-specifieropt
( ptr-declarator )
parameters-and-qualifiers:
( parameter-declaration-clause ) attribute-specifieropt
ref-qualifieropt exception-specificationopt
ptr-operator:
* attribute-specifieropt cv-qualifier-seqopt
&
&&
::opt nested-name-specifier * attribute-specifieropt
cv-qualifier-seq:
cv-qualifier cv-qualifier-seqopt
cv-qualifier:
const
volatile
ref-qualifier:
& &&
declarator-id:
...opt id-expression
::opt nested-name-specifieropt class-name type-id:
cv-qualifier-seqopt
cv-qualifier-seqopt
type-specifier-seq attribute-specifieropt
abstract-declarator:
ptr-operator abstract-declaratoropt direct-abstract-declarator ptr-abstract-declarator noptr-abstract-declaratoropt
...
ptr-abstract-declarator: noptr-abstract-declarator
ptr-operator ptr-abstract-declaratoropt
direct-abstract-declarator noptr-abstract-declarator: direct-abstract-declaratoropt ( parameter-declaration-clause ) cv-qualifier-seqopt ref-qualifieropt exception-specificationopt direct-abstract-declaratoropt ( parameter-declaration-clause ) cv-qualifier-seqopt ref-qualifieropt exception-specificationopt -> type-id direct-abstract-declaratoropt [ constant-expressionopt ] noptr-abstract-declaratoropt parameters-and-qualifiers
noptr-abstract-declaratoropt [ constant-expression ] attribute-specifieropt
( ptr-abstract-declarator )
type-id
abstract-declaratoropt
parameters-and-qualifiers -> attribute-specifieropt
§ A.7
1238
⃝c ISO/IEC
N2798=08-0308
parameter-declaration-clause: parameter-declaration-listopt ...opt parameter-declaration-list , ...
parameter-declaration-list: parameter-declaration
parameter-declaration-list , parameter-declaration
parameter-declaration: decl-specifier-seq decl-specifier-seq decl-specifier-seq decl-specifier-seq
attribute-specifieropt attribute-specifieropt attribute-specifieropt attribute-specifieropt
declarator
declarator = assignment-expression abstract-declaratoropt
abstract-declaratoropt = assignment-expression
function-definition:
decl-specifier-seqopt attribute-specifieropt declarator function-body decl-specifier-seqopt attribute-specifieropt declarator = default ; decl-specifier-seqopt attribute-specifieropt declarator = delete ;
function-body:
ctor-initializeropt compound-statement function-try-block
initializer:
= initializer-clause brace-or-equal-initializer ( expression-list ) braced-init-list
brace-or-equal-initializer: = initializer-clause
braced-init-list
initializer-clause: assignment-expression
braced-init-list
initializer-list: initializer-clause ...opt
initializer-list , initializer-clause ...opt
braced-init-list:
{ initializer-list ,opt }
{}
A.8 Classes
[gram.class]
class-name: identifier
simple-template-id class-specifier:
class-head { member-specificationopt }
class-head:
class-key identifieropt attribute-specifieropt
class-key nested-name-specifier identifier attribute-specifieropt
class-key nested-name-specifieropt simple-template-id attribute-specifieropt
class-key:
class
struct
union
base-clauseopt
base-clauseopt base-clauseopt
§ A.8
1239
⃝c ISO/IEC
N2798=08-0308
member-specification:
member-declaration member-specificationopt access-specifier : member-specificationopt
member-declaration:
member-requirementopt decl-specifier-seqopt
attribute-specifieropt member-declarator-listopt ; member-requirementopt function-definition ;opt
::opt nested-name-specifier templateopt using-declaration static_assert-declaration template-declaration
member-requirement: requires-clause
member-declarator-list: member-declarator
unqualified-id ;
A.9
member-declarator-list , member-declarator
member-declarator:
declarator pure-specifieropt
declarator constant-initializeropt brace-or-equal-initializeropt identifieropt attribute-specifieropt : constant-expression
pure-specifier:
=0
constant-initializer:
= constant-expression
Derived classes
base-clause:
: base-specifier-list
base-specifier-list: base-specifier ...opt
base-specifier-list , base-specifier ...opt
base-specifier:
::opt nested-name-specifieropt class-name attribute-specifieropt
[gram.derived]
virtual access-specifieropt ::opt access-specifier virtualopt ::opt
access-specifier:
private
protected
public
nested-name-specifieropt class-name attribute-specifieropt nested-name-specifieropt class-name attribute-specifieropt
[gram.special]
A.10 Special member functions
conversion-function-id:
operator conversion-type-id
conversion-type-id:
type-specifier-seq attribute-specifieropt
conversion-declarator:
ptr-operator conversion-declaratoropt
ctor-initializer:
: mem-initializer-list
§ A.10
conversion-declaratoropt
1240
⃝c ISO/IEC
N2798=08-0308
mem-initializer-list: mem-initializer ...opt
mem-initializer , mem-initializer-list ...opt
mem-initializer:
mem-initializer-id ( expression-listopt ) mem-initializer-id braced-init-list
mem-initializer-id:
::opt nested-name-specifieropt class-name identifier
A.11 Overloading
operator-function-id: operator operator
[gram.over]
operator: one of
new delete new[]
delete[] +-*/%ˆ&|∼
! = < > += -= *= /= %= ˆ= &= |= << >> >>= <<= == != <= >= && || ++ -- , ->* -> () []
literal-operator-id:
operator "" identifier
A.12 Templates
template-declaration:
exportopt template < template-parameter-list > declaration
template-parameter-list: template-parameter
template-parameter-list , template-parameter
template-parameter: type-parameter
parameter-declaration
constrained-template-parameter
type-parameter:
class ...opt identifieropt
class identifieropt = type-id
typename ...opt identifieropt
typename identifieropt = type-id
template < template-parameter-list > class ...opt identifieropt template < template-parameter-list > class identifieropt = id-expression
[gram.temp]
constrained-template-parameter:
::opt ::opt ::opt
::opt
nested-name-specifieropt
nested-name-specifieropt
nested-name-specifieropt
concept-name ...opt identifieropt
concept-name identifieropt constrained-default-argumentopt
concept-name <
simple-requirement-argument-list > ...opt identifier
nested-name-specifieropt concept-name <
simple-requirement-argument-list > identifier constrained-default-argumentopt
§ A.12
1241
⃝c ISO/IEC
N2798=08-0308
constrained-default-argument: = type-id
= assignment-expression
= id-expression
simple-requirement-argument-list: auto
auto , template-argument-list
simple-template-id:
template-name < template-argument-listopt >
template-id: simple-template-id
operator-function-id < template-argument-listopt > template-name:
identifier
template-argument-list:
template-argument ...opt
template-argument-list , template-argument ...opt
template-argument: constant-expression
type-id id-expression
typename-specifier:
typename ::opt typename ::opt
nested-name-specifier identifier nested-name-specifier templateopt
simple-template-id
explicit-instantiation:
externopt template declaration
explicit-specialization:
template < > declaration
concept-id:
concept-name < template-argument-listopt >
concept-name: identifier
concept-definition:
autoopt concept identifier < template-parameter-list >
refinement-clauseopt concept-body ;opt
concept-body:
{ concept-member-specificationopt }
concept-member-specification:
concept-member-specifier concept-member-specificationopt
concept-member-specifier: associated-function
type-parameter ;
associated-requirements axiom-definition
§ A.12
1242
⃝c ISO/IEC
N2798=08-0308
associated-function: simple-declaration
function-definition template-declaration
associated-requirements: requires-clause ;
axiom-definition: requires-clauseopt
axiom-body:
{ axiom-seqopt }
axiom identifier ( parameter-declaration-clause ) axiom-body
axiom-seq:
axiom axiom-seqopt
axiom: expression-statement
if ( expression ) expression-statement
concept-map-definition:
concept_map ::opt nested-name-specifieropt concept-id { concept-map-member-
specificationopt } ;opt
concept-map-member-specification:
concept-map-member concept-map-member-specificationopt
concept-map-member: simple-declaration function-definition
template-declaration refinement-clause:
: refinement-specifier-list
refinement-specifier-list:
refinement-specifier , refinement-specifier-list
refinement-specifier refinement-specifier:
concept-instance-alias-defopt ::opt nested-name-specifieropt concept-id
concept-instance-alias-def: identifier =
requires-clause:
requires requirement-list
requires ( requirement-list )
requirement-list:
requirement ...opt && requirement-list
requirement ...opt
requirement:
concept-instance-alias-defopt ::opt nested-name-specifieropt concept-id ! ::opt nested-name-specifieropt concept-id
A.13 Exception handling
try-block:
try compound-statement handler-seq
§ A.13
[gram.except]
1243

⃝c ISO/IEC function-try-block:
try ctor-initializeropt compound-statement handler-seq handler-seq:
handler handler-seqopt handler:
catch ( exception-declaration ) compound-statement
exception-declaration:
type-specifier-seq declarator type-specifier-seq abstract-declarator type-specifier-seq
...
throw-expression:
throw assignment-expressionopt
exception-specification:
throw ( type-id-listopt )
type-id-list:
type-id ...opt
type-id-list , type-id ...opt A.14 Preprocessing directives
preprocessing-file: groupopt
group: group-part
group group-part
group-part: if-section
control-line text-line
# non-directive
if-section:
if-group elif-groupsopt else-groupopt endif-line
N2798=08-0308
§ A.14
1244
if-group:
# if
# ifdef
# ifndef
elif-groups: elif-group
constant-expression new-line groupopt identifier new-line groupopt
identifier new-line groupopt
elif-groups elif-group elif-group:
# elif
else-group:
# else
endif-line:
constant-expression new-line groupopt new-line groupopt
new-line
# endif
[gram.cpp]
⃝c ISO/IEC
N2798=08-0308
§ A.14
1245
control-line:
# include
# define
# define
# define
# define
# undef
# line
# error
# pragma
# new-line
pp-tokens new-line
identifier replacement-list new-line
identifier lparen identifier-listopt ) replacement-list new-line identifier lparen ... ) replacement-list new-line
text-line:
pp-tokensopt new-line
non-directive:
pp-tokensopt new-line
lparen:
identifier lparen identifier-list, ... identifier new-line
pp-tokens new-line
pp-tokensopt new-line
pp-tokensopt new-line
) replacement-list new-line
a ( character not immediately preceded by white-space
identifier-list: identifier
identifier-list , identifier replacement-list:
pp-tokensopt
pp-tokens: preprocessing-token
pp-tokens preprocessing-token
new-line:
the new-line character