From Jason Turner

[dcl.fct]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpnqmzkdje/{from.md → to.md} +41 -42
tmp/tmpnqmzkdje/{from.md → to.md} RENAMED
@@ -25,11 +25,11 @@ and the type of the contained *declarator-id* in the declaration `T`
25
  “*derived-declarator-type-list* function of
26
  (*parameter-declaration-clause*) *cv-qualifier-seq*
27
  *ref-qualifier*returning *trailing-return-type*”. The optional
28
  *attribute-specifier-seq* appertains to the function type.
29
 
30
- A type of either form is a *function type*.[^10]
31
 
32
  ``` bnf
33
  parameter-declaration-clause:
34
  parameter-declaration-listₒₚₜ ...ₒₚₜ
35
  parameter-declaration-list ',' ...
@@ -55,18 +55,18 @@ appertains to the parameter.
55
  The *parameter-declaration-clause* determines the arguments that can be
56
  specified, and their processing, when the function is called. the
57
  *parameter-declaration-clause* is used to convert the arguments
58
  specified on the function call; see  [[expr.call]]. If the
59
  *parameter-declaration-clause* is empty, the function takes no
60
- arguments. The parameter list `(void)` is equivalent to the empty
61
- parameter list. Except for this special case, `void` shall not be a
62
- parameter type (though types derived from `void`, such as `void*`, can).
63
- If the *parameter-declaration-clause* terminates with an ellipsis or a
64
- function parameter pack ([[temp.variadic]]), the number of arguments
65
- shall be equal to or greater than the number of parameters that do not
66
- have a default argument and are not function parameter packs. Where
67
- syntactically correct and where “” is not part of an
68
  *abstract-declarator*, “” is synonymous with “”. the declaration
69
 
70
  ``` cpp
71
  int printf(const char*, ...);
72
  ```
@@ -100,20 +100,31 @@ presence or absence of the ellipsis or a function parameter pack is the
100
  function’s *parameter-type-list*. This transformation does not affect
101
  the types of the parameters. For example,
102
  `int(*)(const int p, decltype(p)*)` and `int(*)(int, const int*)` are
103
  identical types.
104
 
105
- A *cv-qualifier-seq* or a *ref-qualifier* shall only be part of:
 
 
106
 
107
  - the function type for a non-static member function,
108
  - the function type to which a pointer to member refers,
109
  - the top-level function type of a function typedef declaration or
110
  *alias-declaration*,
111
  - the *type-id* in the default argument of a *type-parameter* (
112
  [[temp.param]]), or
113
  - the *type-id* of a *template-argument* for a *type-parameter* (
114
- [[temp.names]]).
 
 
 
 
 
 
 
 
 
115
 
116
  The effect of a *cv-qualifier-seq* in a function declarator is not the
117
  same as adding cv-qualification on top of the function type. In the
118
  latter case, the cv-qualifiers are ignored. a function type that has a
119
  *cv-qualifier-seq* is not a cv-qualified type; there are no cv-qualified
@@ -142,20 +153,21 @@ int fseek(FILE*, long, int);
142
  declares a function taking three arguments of the specified types, and
143
  returning `int` ([[dcl.type]]).
144
 
145
  If the type of a parameter includes a type of the form “pointer to array
146
  of unknown bound of `T`” or “reference to array of unknown bound of
147
- `T`,” the program is ill-formed.[^11] Functions shall not have a return
148
  type of type array or function, although they may have a return type of
149
  type pointer or reference to such things. There shall be no arrays of
150
  functions, although there can be arrays of pointers to functions.
151
 
152
  Types shall not be defined in return or parameter types. The type of a
153
  parameter or the return type for a function definition shall not be an
154
- incomplete class type (possibly cv-qualified) unless the function
155
- definition is nested within the *member-specification* for that class
156
- (including definitions in nested classes defined within the class).
 
157
 
158
  A typedef of function type may be used to declare a function but shall
159
  not be used to define a function ([[dcl.fct.def]]).
160
 
161
  ``` cpp
@@ -163,34 +175,18 @@ typedef void F();
163
  F fv; // OK: equivalent to void fv();
164
  F fv { } // ill-formed
165
  void fv() { } // OK: definition of fv
166
  ```
167
 
168
- A typedef of a function type whose declarator includes a
169
- *cv-qualifier-seq* shall be used only to declare the function type for a
170
- non-static member function, to declare the function type to which a
171
- pointer to member refers, or to declare the top-level function type of
172
- another function typedef declaration.
173
-
174
- ``` cpp
175
- typedef int FIC(int) const;
176
- FIC f; // ill-formed: does not declare a member function
177
- struct S {
178
- FIC f; // OK
179
- };
180
- FIC S::*pm = &S::f; // OK
181
- ```
182
-
183
  An identifier can optionally be provided as a parameter name; if present
184
- in a function definition ([[dcl.fct.def]]), it names a parameter
185
- (sometimes called “formal argument”). In particular, parameter names are
186
- also optional in function definitions and names used for a parameter in
187
- different declarations and the definition of a function need not be the
188
- same. If a parameter name is present in a function declaration that is
189
- not a definition, it cannot be used outside of its function declarator
190
- because that is the extent of its potential scope (
191
- [[basic.scope.proto]]).
192
 
193
  the declaration
194
 
195
  ``` cpp
196
  int i,
@@ -224,11 +220,11 @@ IFUNC* fpif(int);
224
  ```
225
 
226
  or
227
 
228
  ``` cpp
229
- auto fpif(int)->int(*)(int)
230
  ```
231
 
232
  A *trailing-return-type* is most useful for a type that would be more
233
  complicated to specify before the *declarator-id*:
234
 
@@ -240,10 +236,13 @@ rather than
240
 
241
  ``` cpp
242
  template <class T, class U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);
243
  ```
244
 
 
 
 
245
  A *declarator-id* or *abstract-declarator* containing an ellipsis shall
246
  only be used in a *parameter-declaration*. Such a
247
  *parameter-declaration* is a parameter pack ([[temp.variadic]]). When
248
  it is part of a *parameter-declaration-clause*, the parameter pack is a
249
  function parameter pack ([[temp.variadic]]). Otherwise, the
@@ -263,9 +262,9 @@ void g() {
263
  ```
264
 
265
  There is a syntactic ambiguity when an ellipsis occurs at the end of a
266
  *parameter-declaration-clause* without a preceding comma. In this case,
267
  the ellipsis is parsed as part of the *abstract-declarator* if the type
268
- of the parameter names a template parameter pack that has not been
269
- expanded; otherwise, it is parsed as part of the
270
- *parameter-declaration-clause*.[^12]
271
 
 
25
  “*derived-declarator-type-list* function of
26
  (*parameter-declaration-clause*) *cv-qualifier-seq*
27
  *ref-qualifier*returning *trailing-return-type*”. The optional
28
  *attribute-specifier-seq* appertains to the function type.
29
 
30
+ A type of either form is a *function type*.[^9]
31
 
32
  ``` bnf
33
  parameter-declaration-clause:
34
  parameter-declaration-listₒₚₜ ...ₒₚₜ
35
  parameter-declaration-list ',' ...
 
55
  The *parameter-declaration-clause* determines the arguments that can be
56
  specified, and their processing, when the function is called. the
57
  *parameter-declaration-clause* is used to convert the arguments
58
  specified on the function call; see  [[expr.call]]. If the
59
  *parameter-declaration-clause* is empty, the function takes no
60
+ arguments. A parameter list consisting of a single unnamed parameter of
61
+ non-dependent type `void` is equivalent to an empty parameter list.
62
+ Except for this special case, a parameter shall not have type *cv*
63
+ `void`. If the *parameter-declaration-clause* terminates with an
64
+ ellipsis or a function parameter pack ([[temp.variadic]]), the number
65
+ of arguments shall be equal to or greater than the number of parameters
66
+ that do not have a default argument and are not function parameter
67
+ packs. Where syntactically correct and where “” is not part of an
68
  *abstract-declarator*, “” is synonymous with “”. the declaration
69
 
70
  ``` cpp
71
  int printf(const char*, ...);
72
  ```
 
100
  function’s *parameter-type-list*. This transformation does not affect
101
  the types of the parameters. For example,
102
  `int(*)(const int p, decltype(p)*)` and `int(*)(int, const int*)` are
103
  identical types.
104
 
105
+ A function type with a *cv-qualifier-seq* or a *ref-qualifier*
106
+ (including a type named by *typedef-name* ([[dcl.typedef]],
107
+ [[temp.param]])) shall appear only as:
108
 
109
  - the function type for a non-static member function,
110
  - the function type to which a pointer to member refers,
111
  - the top-level function type of a function typedef declaration or
112
  *alias-declaration*,
113
  - the *type-id* in the default argument of a *type-parameter* (
114
  [[temp.param]]), or
115
  - the *type-id* of a *template-argument* for a *type-parameter* (
116
+ [[temp.arg.type]]).
117
+
118
+ ``` cpp
119
+ typedef int FIC(int) const;
120
+ FIC f; // ill-formed: does not declare a member function
121
+ struct S {
122
+ FIC f; // OK
123
+ };
124
+ FIC S::*pm = &S::f; // OK
125
+ ```
126
 
127
  The effect of a *cv-qualifier-seq* in a function declarator is not the
128
  same as adding cv-qualification on top of the function type. In the
129
  latter case, the cv-qualifiers are ignored. a function type that has a
130
  *cv-qualifier-seq* is not a cv-qualified type; there are no cv-qualified
 
153
  declares a function taking three arguments of the specified types, and
154
  returning `int` ([[dcl.type]]).
155
 
156
  If the type of a parameter includes a type of the form “pointer to array
157
  of unknown bound of `T`” or “reference to array of unknown bound of
158
+ `T`,” the program is ill-formed.[^10] Functions shall not have a return
159
  type of type array or function, although they may have a return type of
160
  type pointer or reference to such things. There shall be no arrays of
161
  functions, although there can be arrays of pointers to functions.
162
 
163
  Types shall not be defined in return or parameter types. The type of a
164
  parameter or the return type for a function definition shall not be an
165
+ incomplete class type (possibly cv-qualified) unless the function is
166
+ deleted ([[dcl.fct.def.delete]]) or the definition is nested within the
167
+ *member-specification* for that class (including definitions in nested
168
+ classes defined within the class).
169
 
170
  A typedef of function type may be used to declare a function but shall
171
  not be used to define a function ([[dcl.fct.def]]).
172
 
173
  ``` cpp
 
175
  F fv; // OK: equivalent to void fv();
176
  F fv { } // ill-formed
177
  void fv() { } // OK: definition of fv
178
  ```
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  An identifier can optionally be provided as a parameter name; if present
181
+ in a function definition ([[dcl.fct.def]]), it names a parameter. In
182
+ particular, parameter names are also optional in function definitions
183
+ and names used for a parameter in different declarations and the
184
+ definition of a function need not be the same. If a parameter name is
185
+ present in a function declaration that is not a definition, it cannot be
186
+ used outside of its function declarator because that is the extent of
187
+ its potential scope ([[basic.scope.proto]]).
 
188
 
189
  the declaration
190
 
191
  ``` cpp
192
  int i,
 
220
  ```
221
 
222
  or
223
 
224
  ``` cpp
225
+ auto fpif(int)->int(*)(int);
226
  ```
227
 
228
  A *trailing-return-type* is most useful for a type that would be more
229
  complicated to specify before the *declarator-id*:
230
 
 
236
 
237
  ``` cpp
238
  template <class T, class U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);
239
  ```
240
 
241
+ A *non-template function* is a function that is not a function template
242
+ specialization. A function template is not a function.
243
+
244
  A *declarator-id* or *abstract-declarator* containing an ellipsis shall
245
  only be used in a *parameter-declaration*. Such a
246
  *parameter-declaration* is a parameter pack ([[temp.variadic]]). When
247
  it is part of a *parameter-declaration-clause*, the parameter pack is a
248
  function parameter pack ([[temp.variadic]]). Otherwise, the
 
262
  ```
263
 
264
  There is a syntactic ambiguity when an ellipsis occurs at the end of a
265
  *parameter-declaration-clause* without a preceding comma. In this case,
266
  the ellipsis is parsed as part of the *abstract-declarator* if the type
267
+ of the parameter either names a template parameter pack that has not
268
+ been expanded or contains `auto`; otherwise, it is parsed as part of the
269
+ *parameter-declaration-clause*.[^11]
270