tmp/tmpnvfxphym/{from.md → to.md}
RENAMED
|
@@ -1,55 +1,52 @@
|
|
| 1 |
#### Functions <a id="dcl.fct">[[dcl.fct]]</a>
|
| 2 |
|
| 3 |
-
In a declaration `T` `D` where `D` has the form
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
'D1' '(' parameter-declaration-clause ')' cv-qualifier-seqₒₚₜ
|
| 7 |
-
ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ
|
| 8 |
```
|
| 9 |
|
| 10 |
-
|
| 11 |
-
`D1` is “*derived-declarator-type-list* `T`”, the type of the
|
| 12 |
-
*declarator-id* in `D` is “*derived-declarator-type-list* `noexcept`ₒₚₜ
|
| 13 |
-
function of parameter-type-list *cv-qualifier-seq*ₒₚₜ
|
| 14 |
-
*ref-qualifier*ₒₚₜ returning `T`”, where
|
| 15 |
|
| 16 |
-
- the
|
| 17 |
-
*
|
| 18 |
-
- the
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
The
|
|
|
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
``
|
| 26 |
-
'D1' '(' parameter-declaration-clause ')' cv-qualifier-seqₒₚₜ
|
| 27 |
-
ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ trailing-return-type
|
| 28 |
-
```
|
| 29 |
-
|
| 30 |
-
and the type of the contained *declarator-id* in the declaration `T`
|
| 31 |
-
`D1` is “*derived-declarator-type-list* `T`”, `T` shall be the single
|
| 32 |
-
*type-specifier* `auto`. The type of the *declarator-id* in `D` is
|
| 33 |
“*derived-declarator-type-list* `noexcept`ₒₚₜ function of
|
| 34 |
parameter-type-list *cv-qualifier-seq*ₒₚₜ *ref-qualifier*ₒₚₜ returning
|
| 35 |
`U`”, where
|
| 36 |
|
| 37 |
- the parameter-type-list is derived from the
|
| 38 |
-
*parameter-declaration-clause* as described below
|
| 39 |
-
- `U` is the type specified by the *trailing-return-type*, and
|
| 40 |
- the optional `noexcept` is present if and only if the exception
|
| 41 |
-
specification is non-throwing.
|
|
|
|
|
|
|
| 42 |
|
| 43 |
The optional *attribute-specifier-seq* appertains to the function type.
|
| 44 |
|
| 45 |
-
A type of either form is a *function type*.[^2]
|
| 46 |
-
|
| 47 |
``` bnf
|
| 48 |
parameter-declaration-clause:
|
| 49 |
-
|
|
|
|
| 50 |
parameter-declaration-list ',' '...'
|
|
|
|
| 51 |
```
|
| 52 |
|
| 53 |
``` bnf
|
| 54 |
parameter-declaration-list:
|
| 55 |
parameter-declaration
|
|
@@ -73,20 +70,23 @@ specified, and their processing, when the function is called.
|
|
| 73 |
[*Note 1*: The *parameter-declaration-clause* is used to convert the
|
| 74 |
arguments specified on the function call; see
|
| 75 |
[[expr.call]]. — *end note*]
|
| 76 |
|
| 77 |
If the *parameter-declaration-clause* is empty, the function takes no
|
| 78 |
-
arguments. A parameter list consisting of a single unnamed
|
| 79 |
-
non-dependent type `void` is equivalent to an empty
|
| 80 |
-
Except for this special case, a parameter shall not have
|
| 81 |
-
A parameter with volatile-qualified type is deprecated;
|
| 82 |
-
[[depr.volatile.type]]. If the *parameter-declaration-clause*
|
| 83 |
-
with an ellipsis or a function parameter pack
|
| 84 |
-
number of arguments shall be equal to or greater
|
| 85 |
-
parameters that do not have a default argument and
|
| 86 |
-
parameter packs. Where syntactically correct and where
|
| 87 |
-
part of an *abstract-declarator*, “`
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
[*Example 1*:
|
| 90 |
|
| 91 |
The declaration
|
| 92 |
|
|
@@ -145,14 +145,16 @@ void h(int (*)(int)) {} // defines #3
|
|
| 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
|
| 151 |
|
| 152 |
-
- a
|
| 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`.
|
|
@@ -195,31 +197,33 @@ 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
|
| 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]],
|
| 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 {
|
| 218 |
FIC f; // OK
|
| 219 |
};
|
| 220 |
FIC S::*pm = &S::f; // OK
|
|
|
|
| 221 |
```
|
| 222 |
|
| 223 |
— *end example*]
|
| 224 |
|
| 225 |
The effect of a *cv-qualifier-seq* in a function declarator is not the
|
|
@@ -366,24 +370,24 @@ specialization.
|
|
| 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
|
| 372 |
-
*
|
| 373 |
function declaration, in order of appearance. For a
|
| 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
|
| 378 |
-
*
|
| 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 |
-
*
|
| 385 |
|
| 386 |
[*Example 9*:
|
| 387 |
|
| 388 |
``` cpp
|
| 389 |
template<typename T> concept C1 = /* ... */;
|
|
@@ -414,13 +418,12 @@ template<> void g1<int>(const int*, const double&); // OK, specialization of g1<
|
|
| 414 |
```
|
| 415 |
|
| 416 |
— *end example*]
|
| 417 |
|
| 418 |
An abbreviated function template can have a *template-head*. The
|
| 419 |
-
invented *
|
| 420 |
-
|
| 421 |
-
*template-parameter*s.
|
| 422 |
|
| 423 |
[*Example 10*:
|
| 424 |
|
| 425 |
``` cpp
|
| 426 |
template<typename> concept C = /* ... */;
|
|
|
|
| 1 |
#### Functions <a id="dcl.fct">[[dcl.fct]]</a>
|
| 2 |
|
| 3 |
+
In a declaration `T` `D` where `T` may be empty and `D` has the form
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
'D1' '(' parameter-declaration-clause ')' cv-qualifier-seqₒₚₜ
|
| 7 |
+
ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ trailing-return-typeₒₚₜ
|
| 8 |
```
|
| 9 |
|
| 10 |
+
a *derived-declarator-type-list* is determined as follows:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
- If the *unqualified-id* of the *declarator-id* is a
|
| 13 |
+
*conversion-function-id*, the *derived-declarator-type-list* is empty.
|
| 14 |
+
- Otherwise, the *derived-declarator-type-list* is as appears in the
|
| 15 |
+
type “*derived-declarator-type-list* `T`” of the contained
|
| 16 |
+
*declarator-id* in the declaration `T` `D1`.
|
| 17 |
|
| 18 |
+
The declared return type `U` of the function type is determined as
|
| 19 |
+
follows:
|
| 20 |
|
| 21 |
+
- If the *trailing-return-type* is present, `T` shall be the single
|
| 22 |
+
*type-specifier* `auto`, and `U` is the type specified by the
|
| 23 |
+
*trailing-return-type*.
|
| 24 |
+
- Otherwise, if the declaration declares a conversion function, see
|
| 25 |
+
[[class.conv.fct]].
|
| 26 |
+
- Otherwise, `U` is `T`.
|
| 27 |
|
| 28 |
+
The type of the *declarator-id* in `D` is
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
“*derived-declarator-type-list* `noexcept`ₒₚₜ function of
|
| 30 |
parameter-type-list *cv-qualifier-seq*ₒₚₜ *ref-qualifier*ₒₚₜ returning
|
| 31 |
`U`”, where
|
| 32 |
|
| 33 |
- the parameter-type-list is derived from the
|
| 34 |
+
*parameter-declaration-clause* as described below and
|
|
|
|
| 35 |
- the optional `noexcept` is present if and only if the exception
|
| 36 |
+
specification [[except.spec]] is non-throwing.
|
| 37 |
+
|
| 38 |
+
Such a type is a *function type*.[^2]
|
| 39 |
|
| 40 |
The optional *attribute-specifier-seq* appertains to the function type.
|
| 41 |
|
|
|
|
|
|
|
| 42 |
``` bnf
|
| 43 |
parameter-declaration-clause:
|
| 44 |
+
'...'
|
| 45 |
+
parameter-declaration-listₒₚₜ
|
| 46 |
parameter-declaration-list ',' '...'
|
| 47 |
+
parameter-declaration-list '...'
|
| 48 |
```
|
| 49 |
|
| 50 |
``` bnf
|
| 51 |
parameter-declaration-list:
|
| 52 |
parameter-declaration
|
|
|
|
| 70 |
[*Note 1*: The *parameter-declaration-clause* is used to convert the
|
| 71 |
arguments specified on the function call; see
|
| 72 |
[[expr.call]]. — *end note*]
|
| 73 |
|
| 74 |
If the *parameter-declaration-clause* is empty, the function takes no
|
| 75 |
+
arguments. A parameter list consisting of a single unnamed non-object
|
| 76 |
+
parameter of non-dependent type `void` is equivalent to an empty
|
| 77 |
+
parameter list. Except for this special case, a parameter shall not have
|
| 78 |
+
type cv `void`. A parameter with volatile-qualified type is deprecated;
|
| 79 |
+
see [[depr.volatile.type]]. If the *parameter-declaration-clause*
|
| 80 |
+
terminates with an ellipsis or a function parameter pack
|
| 81 |
+
[[temp.variadic]], the number of arguments shall be equal to or greater
|
| 82 |
+
than the number of parameters that do not have a default argument and
|
| 83 |
+
are not function parameter packs. Where syntactically correct and where
|
| 84 |
+
“`...`” is not part of an *abstract-declarator*, “`...`” is synonymous
|
| 85 |
+
with “`, ...`”. A *parameter-declaration-clause* of the form
|
| 86 |
+
*parameter-declaration-list* `...` is deprecated
|
| 87 |
+
[[depr.ellipsis.comma]].
|
| 88 |
|
| 89 |
[*Example 1*:
|
| 90 |
|
| 91 |
The declaration
|
| 92 |
|
|
|
|
| 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 one of:
|
| 151 |
|
| 152 |
+
- a declaration of a member function or member function template
|
| 153 |
+
[[class.mem]], or
|
| 154 |
+
- an explicit instantiation [[temp.explicit]] or explicit specialization
|
| 155 |
+
[[temp.expl.spec]] of a templated member function, or
|
| 156 |
- a *lambda-declarator* [[expr.prim.lambda]].
|
| 157 |
|
| 158 |
A *member-declarator* with an explicit-object-parameter-declaration
|
| 159 |
shall not include a *ref-qualifier* or a *cv-qualifier-seq* and shall
|
| 160 |
not be declared `static` or `virtual`.
|
|
|
|
| 197 |
|
| 198 |
[*Note 4*: The non-object-parameter-type-list consists of the adjusted
|
| 199 |
types of all the non-object parameters. — *end note*]
|
| 200 |
|
| 201 |
A function type with a *cv-qualifier-seq* or a *ref-qualifier*
|
| 202 |
+
(including a type denoted by *typedef-name*
|
| 203 |
[[dcl.typedef]], [[temp.param]]) shall appear only as:
|
| 204 |
|
| 205 |
- the function type for a non-static member function,
|
| 206 |
- the function type to which a pointer to member refers,
|
| 207 |
- the top-level function type of a function typedef declaration or
|
| 208 |
*alias-declaration*,
|
| 209 |
- the *type-id* in the default argument of a *type-parameter*
|
| 210 |
+
[[temp.param]],
|
| 211 |
- the *type-id* of a *template-argument* for a *type-parameter*
|
| 212 |
+
[[temp.arg.type]], or
|
| 213 |
+
- the operand of a *reflect-expression* [[expr.reflect]].
|
| 214 |
|
| 215 |
[*Example 4*:
|
| 216 |
|
| 217 |
``` cpp
|
| 218 |
typedef int FIC(int) const;
|
| 219 |
FIC f; // error: does not declare a member function
|
| 220 |
struct S {
|
| 221 |
FIC f; // OK
|
| 222 |
};
|
| 223 |
FIC S::*pm = &S::f; // OK
|
| 224 |
+
constexpr std::meta::info yeti = ^^void(int) const &; // OK
|
| 225 |
```
|
| 226 |
|
| 227 |
— *end example*]
|
| 228 |
|
| 229 |
The effect of a *cv-qualifier-seq* in a function declarator is not the
|
|
|
|
| 370 |
[*Note 11*: A function template is not a function. — *end note*]
|
| 371 |
|
| 372 |
An *abbreviated function template* is a function declaration that has
|
| 373 |
one or more generic parameter type placeholders [[dcl.spec.auto]]. An
|
| 374 |
abbreviated function template is equivalent to a function template
|
| 375 |
+
[[temp.fct]] whose *template-parameter-list* includes one invented
|
| 376 |
+
*type-parameter* for each generic parameter type placeholder of the
|
| 377 |
function declaration, in order of appearance. For a
|
| 378 |
*placeholder-type-specifier* of the form `auto`, the invented parameter
|
| 379 |
is an unconstrained *type-parameter*. For a *placeholder-type-specifier*
|
| 380 |
of the form *type-constraint* `auto`, the invented parameter is a
|
| 381 |
+
*type-parameter* with that *type-constraint*. The invented
|
| 382 |
+
*type-parameter* declares a template parameter pack if the corresponding
|
| 383 |
*parameter-declaration* declares a function parameter pack. If the
|
| 384 |
placeholder contains `decltype(auto)`, the program is ill-formed. The
|
| 385 |
adjusted function parameters of an abbreviated function template are
|
| 386 |
derived from the *parameter-declaration-clause* by replacing each
|
| 387 |
occurrence of a placeholder with the name of the corresponding invented
|
| 388 |
+
*type-parameter*.
|
| 389 |
|
| 390 |
[*Example 9*:
|
| 391 |
|
| 392 |
``` cpp
|
| 393 |
template<typename T> concept C1 = /* ... */;
|
|
|
|
| 418 |
```
|
| 419 |
|
| 420 |
— *end example*]
|
| 421 |
|
| 422 |
An abbreviated function template can have a *template-head*. The
|
| 423 |
+
invented *type-parameter*s are appended to the *template-parameter-list*
|
| 424 |
+
after the explicitly declared *template-parameter*s.
|
|
|
|
| 425 |
|
| 426 |
[*Example 10*:
|
| 427 |
|
| 428 |
``` cpp
|
| 429 |
template<typename> concept C = /* ... */;
|