tmp/tmp7iguep83/{from.md → to.md}
RENAMED
|
@@ -16,15 +16,76 @@ parameters to agree in number with the arguments in the list.
|
|
| 16 |
- A candidate function having fewer than m parameters is viable only if
|
| 17 |
it has an ellipsis in its parameter list [[dcl.fct]]. For the purposes
|
| 18 |
of overload resolution, any argument for which there is no
|
| 19 |
corresponding parameter is considered to “match the ellipsis”
|
| 20 |
[[over.ics.ellipsis]].
|
| 21 |
-
- A candidate function having more than m parameters is viable only
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
Second, for a function to be viable, if it has associated constraints
|
| 28 |
[[temp.constr.decl]], those constraints shall be satisfied
|
| 29 |
[[temp.constr.constr]].
|
| 30 |
|
|
|
|
| 16 |
- A candidate function having fewer than m parameters is viable only if
|
| 17 |
it has an ellipsis in its parameter list [[dcl.fct]]. For the purposes
|
| 18 |
of overload resolution, any argument for which there is no
|
| 19 |
corresponding parameter is considered to “match the ellipsis”
|
| 20 |
[[over.ics.ellipsis]].
|
| 21 |
+
- A candidate function `C` having more than m parameters is viable only
|
| 22 |
+
if the set of scopes G, as defined below, is not empty. G consists of
|
| 23 |
+
every scope X that satisfies all of the following:
|
| 24 |
+
- There is a declaration of `C`, whose host scope is X, considered by
|
| 25 |
+
the overload resolution.
|
| 26 |
+
- For every $k^\textrm{th}$ parameter P where k \> m, there is a
|
| 27 |
+
reachable declaration, whose host scope is X, that specifies a
|
| 28 |
+
default argument [[dcl.fct.default]] for P.
|
| 29 |
+
|
| 30 |
+
If `C` is selected as the best viable function [[over.match.best]]:
|
| 31 |
+
- G shall contain exactly one scope (call it S).
|
| 32 |
+
- If the candidates are denoted by a *splice-expression*, then S shall
|
| 33 |
+
not be a block scope.
|
| 34 |
+
- The default arguments used in the call to `C` are the default
|
| 35 |
+
arguments specified by the reachable declarations whose host scope
|
| 36 |
+
is S.
|
| 37 |
+
|
| 38 |
+
For the purposes of overload resolution, the parameter list is
|
| 39 |
+
truncated on the right, so that there are exactly m parameters.
|
| 40 |
+
|
| 41 |
+
[*Example 1*:
|
| 42 |
+
|
| 43 |
+
``` cpp
|
| 44 |
+
namespace A {
|
| 45 |
+
extern "C" void f(int, int = 5);
|
| 46 |
+
extern "C" void f(int = 6, int);
|
| 47 |
+
}
|
| 48 |
+
namespace B {
|
| 49 |
+
extern "C" void f(int, int = 7);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
void use() {
|
| 53 |
+
[:^^A::f:](3, 4); // OK, default argument was not used for viability
|
| 54 |
+
[:^^A::f:](3); // error: default argument provided by declarations from two scopes
|
| 55 |
+
[:^^A::f:](); // OK, default arguments provided by declarations in the scope of A
|
| 56 |
+
|
| 57 |
+
using A::f;
|
| 58 |
+
using B::f;
|
| 59 |
+
f(3, 4); // OK, default argument was not used for viability
|
| 60 |
+
f(3); // error: default argument provided by declaration from two scopes
|
| 61 |
+
f(); // OK, default arguments provided by declarations in the scope of A
|
| 62 |
+
|
| 63 |
+
void g(int = 8);
|
| 64 |
+
g(); // OK
|
| 65 |
+
[:^^g:](); // error: host scope is block scope
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
void h(int = 7);
|
| 69 |
+
constexpr std::meta::info r = ^^h;
|
| 70 |
+
void poison() {
|
| 71 |
+
void h(int = 8);
|
| 72 |
+
h(); // OK, calls h(8)
|
| 73 |
+
[:^^h:](); // error: default argument provided by declarations from two scopes
|
| 74 |
+
}
|
| 75 |
+
void call_h() {
|
| 76 |
+
[:^^h:](); // error: default argument provided by declarations from two scopes
|
| 77 |
+
[:r:](); // error: default argument provided by declarations from two scopes
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
template<typename... Ts>
|
| 81 |
+
int k(int = 3, Ts...);
|
| 82 |
+
int i = k<int>(); // error: no default argument for the second parameter
|
| 83 |
+
int j = k<>(); // OK
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
— *end example*]
|
| 87 |
|
| 88 |
Second, for a function to be viable, if it has associated constraints
|
| 89 |
[[temp.constr.decl]], those constraints shall be satisfied
|
| 90 |
[[temp.constr.constr]].
|
| 91 |
|