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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### General <a id="dcl.decl.general">[[dcl.decl.general]]</a>
|
| 2 |
+
|
| 3 |
+
A declarator declares a single variable, function, or type, within a
|
| 4 |
+
declaration. The *init-declarator-list* appearing in a
|
| 5 |
+
*simple-declaration* is a comma-separated sequence of declarators, each
|
| 6 |
+
of which can have an initializer.
|
| 7 |
+
|
| 8 |
+
``` bnf
|
| 9 |
+
init-declarator-list:
|
| 10 |
+
init-declarator
|
| 11 |
+
init-declarator-list ',' init-declarator
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
``` bnf
|
| 15 |
+
init-declarator:
|
| 16 |
+
declarator initializerₒₚₜ
|
| 17 |
+
declarator requires-clause
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
In all contexts, a *declarator* is interpreted as given below. Where an
|
| 21 |
+
*abstract-declarator* can be used (or omitted) in place of a
|
| 22 |
+
*declarator* [[dcl.fct]], [[except.pre]], it is as if a unique
|
| 23 |
+
identifier were included in the appropriate place [[dcl.name]]. The
|
| 24 |
+
preceding specifiers indicate the type, storage class or other
|
| 25 |
+
properties of the entity or entities being declared. Each declarator
|
| 26 |
+
specifies one entity and (optionally) names it and/or modifies the type
|
| 27 |
+
of the specifiers with operators such as `*` (pointer to) and `()`
|
| 28 |
+
(function returning).
|
| 29 |
+
|
| 30 |
+
[*Note 1*: An *init-declarator* can also specify an initializer
|
| 31 |
+
[[dcl.init]]. — *end note*]
|
| 32 |
+
|
| 33 |
+
Each *init-declarator* or *member-declarator* in a declaration is
|
| 34 |
+
analyzed separately as if it were in a declaration by itself.
|
| 35 |
+
|
| 36 |
+
[*Note 2*:
|
| 37 |
+
|
| 38 |
+
A declaration with several declarators is usually equivalent to the
|
| 39 |
+
corresponding sequence of declarations each with a single declarator.
|
| 40 |
+
That is,
|
| 41 |
+
|
| 42 |
+
``` cpp
|
| 43 |
+
T D1, D2, ... Dn;
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
is usually equivalent to
|
| 47 |
+
|
| 48 |
+
``` cpp
|
| 49 |
+
T D1; T D2; ... T Dn;
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
where `T` is a *decl-specifier-seq* and each `Di` is an
|
| 53 |
+
*init-declarator* or *member-declarator*. One exception is when a name
|
| 54 |
+
introduced by one of the *declarator*s hides a type name used by the
|
| 55 |
+
*decl-specifier*s, so that when the same *decl-specifier*s are used in a
|
| 56 |
+
subsequent declaration, they do not have the same meaning, as in
|
| 57 |
+
|
| 58 |
+
``` cpp
|
| 59 |
+
struct S { ... };
|
| 60 |
+
S S, T; // declare two instances of struct S
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
which is not equivalent to
|
| 64 |
+
|
| 65 |
+
``` cpp
|
| 66 |
+
struct S { ... };
|
| 67 |
+
S S;
|
| 68 |
+
S T; // error
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
Another exception is when `T` is `auto` [[dcl.spec.auto]], for example:
|
| 72 |
+
|
| 73 |
+
``` cpp
|
| 74 |
+
auto i = 1, j = 2.0; // error: deduced types for i and j do not match
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
as opposed to
|
| 78 |
+
|
| 79 |
+
``` cpp
|
| 80 |
+
auto i = 1; // OK, i deduced to have type int
|
| 81 |
+
auto j = 2.0; // OK, j deduced to have type double
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
— *end note*]
|
| 85 |
+
|
| 86 |
+
The optional *requires-clause* in an *init-declarator* or
|
| 87 |
+
*member-declarator* shall be present only if the declarator declares a
|
| 88 |
+
templated function [[temp.pre]]. When present after a declarator, the
|
| 89 |
+
*requires-clause* is called the *trailing *requires-clause**. The
|
| 90 |
+
trailing *requires-clause* introduces the *constraint-expression* that
|
| 91 |
+
results from interpreting its *constraint-logical-or-expression* as a
|
| 92 |
+
*constraint-expression*.
|
| 93 |
+
|
| 94 |
+
[*Example 1*:
|
| 95 |
+
|
| 96 |
+
``` cpp
|
| 97 |
+
void f1(int a) requires true; // error: non-templated function
|
| 98 |
+
template<typename T>
|
| 99 |
+
auto f2(T a) -> bool requires true; // OK
|
| 100 |
+
template<typename T>
|
| 101 |
+
auto f3(T a) requires true -> bool; // error: requires-clause precedes trailing-return-type
|
| 102 |
+
void (*pf)() requires true; // error: constraint on a variable
|
| 103 |
+
void g(int (*)() requires true); // error: constraint on a parameter-declaration
|
| 104 |
+
|
| 105 |
+
auto* p = new void(*)(char) requires true; // error: not a function declaration
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
— *end example*]
|
| 109 |
+
|
| 110 |
+
Declarators have the syntax
|
| 111 |
+
|
| 112 |
+
``` bnf
|
| 113 |
+
declarator:
|
| 114 |
+
ptr-declarator
|
| 115 |
+
noptr-declarator parameters-and-qualifiers trailing-return-type
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
``` bnf
|
| 119 |
+
ptr-declarator:
|
| 120 |
+
noptr-declarator
|
| 121 |
+
ptr-operator ptr-declarator
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
``` bnf
|
| 125 |
+
noptr-declarator:
|
| 126 |
+
declarator-id attribute-specifier-seqₒₚₜ
|
| 127 |
+
noptr-declarator parameters-and-qualifiers
|
| 128 |
+
noptr-declarator '[' constant-expressionₒₚₜ ']' attribute-specifier-seqₒₚₜ
|
| 129 |
+
'(' ptr-declarator ')'
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
``` bnf
|
| 133 |
+
parameters-and-qualifiers:
|
| 134 |
+
'(' parameter-declaration-clause ')' cv-qualifier-seqₒₚₜ
|
| 135 |
+
ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
``` bnf
|
| 139 |
+
trailing-return-type:
|
| 140 |
+
'->' type-id
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
``` bnf
|
| 144 |
+
ptr-operator:
|
| 145 |
+
'*' attribute-specifier-seqₒₚₜ cv-qualifier-seqₒₚₜ
|
| 146 |
+
'&' attribute-specifier-seqₒₚₜ
|
| 147 |
+
'&&' attribute-specifier-seqₒₚₜ
|
| 148 |
+
nested-name-specifier '*' attribute-specifier-seqₒₚₜ cv-qualifier-seqₒₚₜ
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
``` bnf
|
| 152 |
+
cv-qualifier-seq:
|
| 153 |
+
cv-qualifier cv-qualifier-seqₒₚₜ
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
``` bnf
|
| 157 |
+
cv-qualifier:
|
| 158 |
+
const
|
| 159 |
+
volatile
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
``` bnf
|
| 163 |
+
ref-qualifier:
|
| 164 |
+
'&'
|
| 165 |
+
'&&'
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
``` bnf
|
| 169 |
+
declarator-id:
|
| 170 |
+
'...'ₒₚₜ id-expression
|
| 171 |
+
```
|
| 172 |
+
|