- tmp/tmpb0zwb4qb/{from.md → to.md} +108 -42
tmp/tmpb0zwb4qb/{from.md → to.md}
RENAMED
|
@@ -56,13 +56,13 @@ parameter-declaration-list:
|
|
| 56 |
parameter-declaration-list ',' parameter-declaration
|
| 57 |
```
|
| 58 |
|
| 59 |
``` bnf
|
| 60 |
parameter-declaration:
|
| 61 |
-
attribute-specifier-seqₒₚₜ decl-specifier-seq declarator
|
| 62 |
attribute-specifier-seqₒₚₜ decl-specifier-seq declarator '=' initializer-clause
|
| 63 |
-
attribute-specifier-seqₒₚₜ decl-specifier-seq abstract-declaratorₒₚₜ
|
| 64 |
attribute-specifier-seqₒₚₜ decl-specifier-seq abstract-declaratorₒₚₜ '=' initializer-clause
|
| 65 |
```
|
| 66 |
|
| 67 |
The optional *attribute-specifier-seq* in a *parameter-declaration*
|
| 68 |
appertains to the parameter.
|
|
@@ -111,12 +111,12 @@ However, the first argument must be of a type that can be converted to a
|
|
| 111 |
accessing arguments passed using the ellipsis (see [[expr.call]] and
|
| 112 |
[[support.runtime]]). — *end note*]
|
| 113 |
|
| 114 |
The type of a function is determined using the following rules. The type
|
| 115 |
of each parameter (including function parameter packs) is determined
|
| 116 |
-
from its own *
|
| 117 |
-
|
| 118 |
function type `T` is adjusted to be “pointer to `T`”. After producing
|
| 119 |
the list of parameter types, any top-level *cv-qualifier*s modifying a
|
| 120 |
parameter type are deleted when forming the function type. The resulting
|
| 121 |
list of transformed parameter types and the presence or absence of the
|
| 122 |
ellipsis or a function parameter pack is the function’s
|
|
@@ -124,24 +124,94 @@ ellipsis or a function parameter pack is the function’s
|
|
| 124 |
|
| 125 |
[*Note 3*: This transformation does not affect the types of the
|
| 126 |
parameters. For example, `int(*)(const int p, decltype(p)*)` and
|
| 127 |
`int(*)(int, const int*)` are identical types. — *end note*]
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
A function type with a *cv-qualifier-seq* or a *ref-qualifier*
|
| 130 |
-
(including a type named by *typedef-name*
|
| 131 |
-
[[temp.param]])
|
| 132 |
|
| 133 |
- the function type for a non-static member function,
|
| 134 |
- the function type to which a pointer to member refers,
|
| 135 |
- the top-level function type of a function typedef declaration or
|
| 136 |
*alias-declaration*,
|
| 137 |
- the *type-id* in the default argument of a *type-parameter*
|
| 138 |
[[temp.param]], or
|
| 139 |
- the *type-id* of a *template-argument* for a *type-parameter*
|
| 140 |
[[temp.arg.type]].
|
| 141 |
|
| 142 |
-
[*Example
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
typedef int FIC(int) const;
|
| 146 |
FIC f; // error: does not declare a member function
|
| 147 |
struct S {
|
|
@@ -154,35 +224,35 @@ FIC S::*pm = &S::f; // OK
|
|
| 154 |
|
| 155 |
The effect of a *cv-qualifier-seq* in a function declarator is not the
|
| 156 |
same as adding cv-qualification on top of the function type. In the
|
| 157 |
latter case, the cv-qualifiers are ignored.
|
| 158 |
|
| 159 |
-
[*Note
|
| 160 |
cv-qualified type; there are no cv-qualified function
|
| 161 |
types. — *end note*]
|
| 162 |
|
| 163 |
-
[*Example
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
typedef void F();
|
| 167 |
struct S {
|
| 168 |
-
const F f; // OK
|
| 169 |
};
|
| 170 |
```
|
| 171 |
|
| 172 |
— *end example*]
|
| 173 |
|
| 174 |
The return type, the parameter-type-list, the *ref-qualifier*, the
|
| 175 |
*cv-qualifier-seq*, and the exception specification, but not the default
|
| 176 |
arguments [[dcl.fct.default]] or the trailing *requires-clause*
|
| 177 |
[[dcl.decl]], are part of the function type.
|
| 178 |
|
| 179 |
-
[*Note
|
| 180 |
initializations of pointers to functions, references to functions, and
|
| 181 |
pointers to member functions. — *end note*]
|
| 182 |
|
| 183 |
-
[*Example
|
| 184 |
|
| 185 |
The declaration
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
int fseek(FILE*, long, int);
|
|
@@ -191,50 +261,46 @@ int fseek(FILE*, long, int);
|
|
| 191 |
declares a function taking three arguments of the specified types, and
|
| 192 |
returning `int` [[dcl.type]].
|
| 193 |
|
| 194 |
— *end example*]
|
| 195 |
|
| 196 |
-
A single name can be used for several different functions in
|
| 197 |
-
scope; this is function overloading [[over]].
|
| 198 |
-
function shall have equivalent return types, parameter-type-lists, and
|
| 199 |
-
*requires-clause*s [[temp.over.link]].
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
| 205 |
|
| 206 |
A volatile-qualified return type is deprecated; see
|
| 207 |
[[depr.volatile.type]].
|
| 208 |
|
| 209 |
Types shall not be defined in return or parameter types.
|
| 210 |
|
| 211 |
A typedef of function type may be used to declare a function but shall
|
| 212 |
not be used to define a function [[dcl.fct.def]].
|
| 213 |
|
| 214 |
-
[*Example
|
| 215 |
|
| 216 |
``` cpp
|
| 217 |
typedef void F();
|
| 218 |
-
F fv; // OK
|
| 219 |
F fv { } // error
|
| 220 |
-
void fv() { } // OK
|
| 221 |
```
|
| 222 |
|
| 223 |
— *end example*]
|
| 224 |
|
| 225 |
An identifier can optionally be provided as a parameter name; if present
|
| 226 |
in a function definition [[dcl.fct.def]], it names a parameter.
|
| 227 |
|
| 228 |
-
[*Note
|
| 229 |
definitions and names used for a parameter in different declarations and
|
| 230 |
-
the definition of a function need not be the same.
|
| 231 |
-
is present in a function declaration that is not a definition, it cannot
|
| 232 |
-
be used outside of its function declarator because that is the extent of
|
| 233 |
-
its potential scope [[basic.scope.param]]. — *end note*]
|
| 234 |
|
| 235 |
-
[*Example
|
| 236 |
|
| 237 |
The declaration
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
int i,
|
|
@@ -260,15 +326,15 @@ calling of a function `fpi`, and then using indirection through the
|
|
| 260 |
to indicate that indirection through a pointer to a function yields a
|
| 261 |
function, which is then called.
|
| 262 |
|
| 263 |
— *end example*]
|
| 264 |
|
| 265 |
-
[*Note
|
| 266 |
|
| 267 |
Typedefs and *trailing-return-type*s are sometimes convenient when the
|
| 268 |
return type of a function is complex. For example, the function `fpif`
|
| 269 |
-
above
|
| 270 |
|
| 271 |
``` cpp
|
| 272 |
typedef int IFUNC(int);
|
| 273 |
IFUNC* fpif(int);
|
| 274 |
```
|
|
@@ -295,11 +361,11 @@ template <class T, class U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);
|
|
| 295 |
— *end note*]
|
| 296 |
|
| 297 |
A *non-template function* is a function that is not a function template
|
| 298 |
specialization.
|
| 299 |
|
| 300 |
-
[*Note
|
| 301 |
|
| 302 |
An *abbreviated function template* is a function declaration that has
|
| 303 |
one or more generic parameter type placeholders [[dcl.spec.auto]]. An
|
| 304 |
abbreviated function template is equivalent to a function template
|
| 305 |
[[temp.fct]] whose *template-parameter-list* includes one invented type
|
|
@@ -308,18 +374,18 @@ function declaration, in order of appearance. For a
|
|
| 308 |
*placeholder-type-specifier* of the form `auto`, the invented parameter
|
| 309 |
is an unconstrained *type-parameter*. For a *placeholder-type-specifier*
|
| 310 |
of the form *type-constraint* `auto`, the invented parameter is a
|
| 311 |
*type-parameter* with that *type-constraint*. The invented type
|
| 312 |
*template-parameter* is a template parameter pack if the corresponding
|
| 313 |
-
*parameter-declaration* declares a function parameter pack
|
| 314 |
-
|
| 315 |
-
|
| 316 |
derived from the *parameter-declaration-clause* by replacing each
|
| 317 |
occurrence of a placeholder with the name of the corresponding invented
|
| 318 |
*template-parameter*.
|
| 319 |
|
| 320 |
-
[*Example
|
| 321 |
|
| 322 |
``` cpp
|
| 323 |
template<typename T> concept C1 = /* ... */;
|
| 324 |
template<typename T> concept C2 = /* ... */;
|
| 325 |
template<typename... Ts> concept C3 = /* ... */;
|
|
@@ -328,12 +394,12 @@ void g1(const C1 auto*, C2 auto&);
|
|
| 328 |
void g2(C1 auto&...);
|
| 329 |
void g3(C3 auto...);
|
| 330 |
void g4(C3 auto);
|
| 331 |
```
|
| 332 |
|
| 333 |
-
|
| 334 |
-
|
| 335 |
|
| 336 |
``` cpp
|
| 337 |
template<C1 T, C2 U> void g1(const T*, U&);
|
| 338 |
template<C1... Ts> void g2(Ts&...);
|
| 339 |
template<C3... Ts> void g3(Ts...);
|
|
@@ -348,15 +414,15 @@ template<> void g1<int>(const int*, const double&); // OK, specialization of g1<
|
|
| 348 |
```
|
| 349 |
|
| 350 |
— *end example*]
|
| 351 |
|
| 352 |
An abbreviated function template can have a *template-head*. The
|
| 353 |
-
invented *template-
|
| 354 |
*template-parameter-list* after the explicitly declared
|
| 355 |
-
*template-
|
| 356 |
|
| 357 |
-
[*Example
|
| 358 |
|
| 359 |
``` cpp
|
| 360 |
template<typename> concept C = /* ... */;
|
| 361 |
|
| 362 |
template <typename T, C U>
|
|
@@ -386,11 +452,11 @@ only be used in a *parameter-declaration*. When it is part of a
|
|
| 386 |
function parameter pack [[temp.variadic]]. Otherwise, the
|
| 387 |
*parameter-declaration* is part of a *template-parameter-list* and
|
| 388 |
declares a template parameter pack; see [[temp.param]]. A function
|
| 389 |
parameter pack is a pack expansion [[temp.variadic]].
|
| 390 |
|
| 391 |
-
[*Example
|
| 392 |
|
| 393 |
``` cpp
|
| 394 |
template<typename... T> void f(T (* ...t)(int, int));
|
| 395 |
|
| 396 |
int add(int, int);
|
|
|
|
| 56 |
parameter-declaration-list ',' parameter-declaration
|
| 57 |
```
|
| 58 |
|
| 59 |
``` bnf
|
| 60 |
parameter-declaration:
|
| 61 |
+
attribute-specifier-seqₒₚₜ thisₒₚₜ decl-specifier-seq declarator
|
| 62 |
attribute-specifier-seqₒₚₜ decl-specifier-seq declarator '=' initializer-clause
|
| 63 |
+
attribute-specifier-seqₒₚₜ thisₒₚₜ decl-specifier-seq abstract-declaratorₒₚₜ
|
| 64 |
attribute-specifier-seqₒₚₜ decl-specifier-seq abstract-declaratorₒₚₜ '=' initializer-clause
|
| 65 |
```
|
| 66 |
|
| 67 |
The optional *attribute-specifier-seq* in a *parameter-declaration*
|
| 68 |
appertains to the parameter.
|
|
|
|
| 111 |
accessing arguments passed using the ellipsis (see [[expr.call]] and
|
| 112 |
[[support.runtime]]). — *end note*]
|
| 113 |
|
| 114 |
The type of a function is determined using the following rules. The type
|
| 115 |
of each parameter (including function parameter packs) is determined
|
| 116 |
+
from its own *parameter-declaration* [[dcl.decl]]. After determining the
|
| 117 |
+
type of each parameter, any parameter of type “array of `T`” or of
|
| 118 |
function type `T` is adjusted to be “pointer to `T`”. After producing
|
| 119 |
the list of parameter types, any top-level *cv-qualifier*s modifying a
|
| 120 |
parameter type are deleted when forming the function type. The resulting
|
| 121 |
list of transformed parameter types and the presence or absence of the
|
| 122 |
ellipsis or a function parameter pack is the function’s
|
|
|
|
| 124 |
|
| 125 |
[*Note 3*: This transformation does not affect the types of the
|
| 126 |
parameters. For example, `int(*)(const int p, decltype(p)*)` and
|
| 127 |
`int(*)(int, const int*)` are identical types. — *end note*]
|
| 128 |
|
| 129 |
+
[*Example 2*:
|
| 130 |
+
|
| 131 |
+
``` cpp
|
| 132 |
+
void f(char*); // #1
|
| 133 |
+
void f(char[]) {} // defines #1
|
| 134 |
+
void f(const char*) {} // OK, another overload
|
| 135 |
+
void f(char *const) {} // error: redefines #1
|
| 136 |
+
|
| 137 |
+
void g(char(*)[2]); // #2
|
| 138 |
+
void g(char[3][2]) {} // defines #2
|
| 139 |
+
void g(char[3][3]) {} // OK, another overload
|
| 140 |
+
|
| 141 |
+
void h(int x(const int)); // #3
|
| 142 |
+
void h(int (*)(int)) {} // defines #3
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
— *end example*]
|
| 146 |
+
|
| 147 |
+
An *explicit-object-parameter-declaration* is a *parameter-declaration*
|
| 148 |
+
with a `this` specifier. An explicit-object-parameter-declaration shall
|
| 149 |
+
appear only as the first *parameter-declaration* of a
|
| 150 |
+
*parameter-declaration-list* of either:
|
| 151 |
+
|
| 152 |
+
- a *member-declarator* that declares a member function [[class.mem]],
|
| 153 |
+
or
|
| 154 |
+
- a *lambda-declarator* [[expr.prim.lambda]].
|
| 155 |
+
|
| 156 |
+
A *member-declarator* with an explicit-object-parameter-declaration
|
| 157 |
+
shall not include a *ref-qualifier* or a *cv-qualifier-seq* and shall
|
| 158 |
+
not be declared `static` or `virtual`.
|
| 159 |
+
|
| 160 |
+
[*Example 3*:
|
| 161 |
+
|
| 162 |
+
``` cpp
|
| 163 |
+
struct C {
|
| 164 |
+
void f(this C& self);
|
| 165 |
+
template <typename Self> void g(this Self&& self, int);
|
| 166 |
+
|
| 167 |
+
void h(this C) const; // error: const not allowed here
|
| 168 |
+
};
|
| 169 |
+
|
| 170 |
+
void test(C c) {
|
| 171 |
+
c.f(); // OK, calls C::f
|
| 172 |
+
c.g(42); // OK, calls C::g<C&>
|
| 173 |
+
std::move(c).g(42); // OK, calls C::g<C>
|
| 174 |
+
}
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
— *end example*]
|
| 178 |
+
|
| 179 |
+
A function parameter declared with an
|
| 180 |
+
explicit-object-parameter-declaration is an *explicit object parameter*.
|
| 181 |
+
An explicit object parameter shall not be a function parameter pack
|
| 182 |
+
[[temp.variadic]]. An *explicit object member function* is a non-static
|
| 183 |
+
member function with an explicit object parameter. An
|
| 184 |
+
*implicit object member function* is a non-static member function
|
| 185 |
+
without an explicit object parameter.
|
| 186 |
+
|
| 187 |
+
The *object parameter* of a non-static member function is either the
|
| 188 |
+
explicit object parameter or the implicit object parameter
|
| 189 |
+
[[over.match.funcs]].
|
| 190 |
+
|
| 191 |
+
A *non-object parameter* is a function parameter that is not the
|
| 192 |
+
explicit object parameter. The *non-object-parameter-type-list* of a
|
| 193 |
+
member function is the parameter-type-list of that function with the
|
| 194 |
+
explicit object parameter, if any, omitted.
|
| 195 |
+
|
| 196 |
+
[*Note 4*: The non-object-parameter-type-list consists of the adjusted
|
| 197 |
+
types of all the non-object parameters. — *end note*]
|
| 198 |
+
|
| 199 |
A function type with a *cv-qualifier-seq* or a *ref-qualifier*
|
| 200 |
+
(including a type named by *typedef-name*
|
| 201 |
+
[[dcl.typedef]], [[temp.param]]) shall appear only as:
|
| 202 |
|
| 203 |
- the function type for a non-static member function,
|
| 204 |
- the function type to which a pointer to member refers,
|
| 205 |
- the top-level function type of a function typedef declaration or
|
| 206 |
*alias-declaration*,
|
| 207 |
- the *type-id* in the default argument of a *type-parameter*
|
| 208 |
[[temp.param]], or
|
| 209 |
- the *type-id* of a *template-argument* for a *type-parameter*
|
| 210 |
[[temp.arg.type]].
|
| 211 |
|
| 212 |
+
[*Example 4*:
|
| 213 |
|
| 214 |
``` cpp
|
| 215 |
typedef int FIC(int) const;
|
| 216 |
FIC f; // error: does not declare a member function
|
| 217 |
struct S {
|
|
|
|
| 224 |
|
| 225 |
The effect of a *cv-qualifier-seq* in a function declarator is not the
|
| 226 |
same as adding cv-qualification on top of the function type. In the
|
| 227 |
latter case, the cv-qualifiers are ignored.
|
| 228 |
|
| 229 |
+
[*Note 5*: A function type that has a *cv-qualifier-seq* is not a
|
| 230 |
cv-qualified type; there are no cv-qualified function
|
| 231 |
types. — *end note*]
|
| 232 |
|
| 233 |
+
[*Example 5*:
|
| 234 |
|
| 235 |
``` cpp
|
| 236 |
typedef void F();
|
| 237 |
struct S {
|
| 238 |
+
const F f; // OK, equivalent to: void f();
|
| 239 |
};
|
| 240 |
```
|
| 241 |
|
| 242 |
— *end example*]
|
| 243 |
|
| 244 |
The return type, the parameter-type-list, the *ref-qualifier*, the
|
| 245 |
*cv-qualifier-seq*, and the exception specification, but not the default
|
| 246 |
arguments [[dcl.fct.default]] or the trailing *requires-clause*
|
| 247 |
[[dcl.decl]], are part of the function type.
|
| 248 |
|
| 249 |
+
[*Note 6*: Function types are checked during the assignments and
|
| 250 |
initializations of pointers to functions, references to functions, and
|
| 251 |
pointers to member functions. — *end note*]
|
| 252 |
|
| 253 |
+
[*Example 6*:
|
| 254 |
|
| 255 |
The declaration
|
| 256 |
|
| 257 |
``` cpp
|
| 258 |
int fseek(FILE*, long, int);
|
|
|
|
| 261 |
declares a function taking three arguments of the specified types, and
|
| 262 |
returning `int` [[dcl.type]].
|
| 263 |
|
| 264 |
— *end example*]
|
| 265 |
|
| 266 |
+
[*Note 7*: A single name can be used for several different functions in
|
| 267 |
+
a single scope; this is function overloading [[over]]. — *end note*]
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
The return type shall be a non-array object type, a reference type, or
|
| 270 |
+
cv `void`.
|
| 271 |
+
|
| 272 |
+
[*Note 8*: An array of placeholder type is considered an array
|
| 273 |
+
type. — *end note*]
|
| 274 |
|
| 275 |
A volatile-qualified return type is deprecated; see
|
| 276 |
[[depr.volatile.type]].
|
| 277 |
|
| 278 |
Types shall not be defined in return or parameter types.
|
| 279 |
|
| 280 |
A typedef of function type may be used to declare a function but shall
|
| 281 |
not be used to define a function [[dcl.fct.def]].
|
| 282 |
|
| 283 |
+
[*Example 7*:
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
typedef void F();
|
| 287 |
+
F fv; // OK, equivalent to void fv();
|
| 288 |
F fv { } // error
|
| 289 |
+
void fv() { } // OK, definition of fv
|
| 290 |
```
|
| 291 |
|
| 292 |
— *end example*]
|
| 293 |
|
| 294 |
An identifier can optionally be provided as a parameter name; if present
|
| 295 |
in a function definition [[dcl.fct.def]], it names a parameter.
|
| 296 |
|
| 297 |
+
[*Note 9*: In particular, parameter names are also optional in function
|
| 298 |
definitions and names used for a parameter in different declarations and
|
| 299 |
+
the definition of a function need not be the same. — *end note*]
|
|
|
|
|
|
|
|
|
|
| 300 |
|
| 301 |
+
[*Example 8*:
|
| 302 |
|
| 303 |
The declaration
|
| 304 |
|
| 305 |
``` cpp
|
| 306 |
int i,
|
|
|
|
| 326 |
to indicate that indirection through a pointer to a function yields a
|
| 327 |
function, which is then called.
|
| 328 |
|
| 329 |
— *end example*]
|
| 330 |
|
| 331 |
+
[*Note 10*:
|
| 332 |
|
| 333 |
Typedefs and *trailing-return-type*s are sometimes convenient when the
|
| 334 |
return type of a function is complex. For example, the function `fpif`
|
| 335 |
+
above can be declared
|
| 336 |
|
| 337 |
``` cpp
|
| 338 |
typedef int IFUNC(int);
|
| 339 |
IFUNC* fpif(int);
|
| 340 |
```
|
|
|
|
| 361 |
— *end note*]
|
| 362 |
|
| 363 |
A *non-template function* is a function that is not a function template
|
| 364 |
specialization.
|
| 365 |
|
| 366 |
+
[*Note 11*: A function template is not a function. — *end note*]
|
| 367 |
|
| 368 |
An *abbreviated function template* is a function declaration that has
|
| 369 |
one or more generic parameter type placeholders [[dcl.spec.auto]]. An
|
| 370 |
abbreviated function template is equivalent to a function template
|
| 371 |
[[temp.fct]] whose *template-parameter-list* includes one invented type
|
|
|
|
| 374 |
*placeholder-type-specifier* of the form `auto`, the invented parameter
|
| 375 |
is an unconstrained *type-parameter*. For a *placeholder-type-specifier*
|
| 376 |
of the form *type-constraint* `auto`, the invented parameter is a
|
| 377 |
*type-parameter* with that *type-constraint*. The invented type
|
| 378 |
*template-parameter* is a template parameter pack if the corresponding
|
| 379 |
+
*parameter-declaration* declares a function parameter pack. If the
|
| 380 |
+
placeholder contains `decltype(auto)`, the program is ill-formed. The
|
| 381 |
+
adjusted function parameters of an abbreviated function template are
|
| 382 |
derived from the *parameter-declaration-clause* by replacing each
|
| 383 |
occurrence of a placeholder with the name of the corresponding invented
|
| 384 |
*template-parameter*.
|
| 385 |
|
| 386 |
+
[*Example 9*:
|
| 387 |
|
| 388 |
``` cpp
|
| 389 |
template<typename T> concept C1 = /* ... */;
|
| 390 |
template<typename T> concept C2 = /* ... */;
|
| 391 |
template<typename... Ts> concept C3 = /* ... */;
|
|
|
|
| 394 |
void g2(C1 auto&...);
|
| 395 |
void g3(C3 auto...);
|
| 396 |
void g4(C3 auto);
|
| 397 |
```
|
| 398 |
|
| 399 |
+
The declarations above are functionally equivalent (but not equivalent)
|
| 400 |
+
to their respective declarations below:
|
| 401 |
|
| 402 |
``` cpp
|
| 403 |
template<C1 T, C2 U> void g1(const T*, U&);
|
| 404 |
template<C1... Ts> void g2(Ts&...);
|
| 405 |
template<C3... Ts> void g3(Ts...);
|
|
|
|
| 414 |
```
|
| 415 |
|
| 416 |
— *end example*]
|
| 417 |
|
| 418 |
An abbreviated function template can have a *template-head*. The
|
| 419 |
+
invented *template-parameter*s are appended to the
|
| 420 |
*template-parameter-list* after the explicitly declared
|
| 421 |
+
*template-parameter*s.
|
| 422 |
|
| 423 |
+
[*Example 10*:
|
| 424 |
|
| 425 |
``` cpp
|
| 426 |
template<typename> concept C = /* ... */;
|
| 427 |
|
| 428 |
template <typename T, C U>
|
|
|
|
| 452 |
function parameter pack [[temp.variadic]]. Otherwise, the
|
| 453 |
*parameter-declaration* is part of a *template-parameter-list* and
|
| 454 |
declares a template parameter pack; see [[temp.param]]. A function
|
| 455 |
parameter pack is a pack expansion [[temp.variadic]].
|
| 456 |
|
| 457 |
+
[*Example 11*:
|
| 458 |
|
| 459 |
``` cpp
|
| 460 |
template<typename... T> void f(T (* ...t)(int, int));
|
| 461 |
|
| 462 |
int add(int, int);
|