tmp/tmp4a9805s4/{from.md → to.md}
RENAMED
|
@@ -169,15 +169,17 @@ that allow a difference:
|
|
| 169 |
template <typename... T> struct X;
|
| 170 |
template <> struct X<> {};
|
| 171 |
template <typename T, typename... Ts>
|
| 172 |
struct X<T, Ts...> : X<Ts...> {};
|
| 173 |
struct D : X<int> {};
|
|
|
|
| 174 |
|
| 175 |
template <typename... T>
|
| 176 |
int f(const X<T...>&);
|
| 177 |
int x = f(D()); // calls f<int>, not f<>
|
| 178 |
// B is X<>, C is X<int>
|
|
|
|
| 179 |
```
|
| 180 |
|
| 181 |
— *end example*]
|
| 182 |
|
| 183 |
These alternatives are considered only if type deduction would otherwise
|
|
@@ -236,36 +238,5 @@ template <class T> T g(T);
|
|
| 236 |
int i = f(1, g); // calls f(int, int (*)(int))
|
| 237 |
```
|
| 238 |
|
| 239 |
— *end example*]
|
| 240 |
|
| 241 |
-
If deduction succeeds for all parameters that contain
|
| 242 |
-
*template-parameter*s that participate in template argument deduction,
|
| 243 |
-
and all template arguments are explicitly specified, deduced, or
|
| 244 |
-
obtained from default template arguments, remaining parameters are then
|
| 245 |
-
compared with the corresponding arguments. For each remaining parameter
|
| 246 |
-
`P` with a type that was non-dependent before substitution of any
|
| 247 |
-
explicitly-specified template arguments, if the corresponding argument
|
| 248 |
-
`A` cannot be implicitly converted to `P`, deduction fails.
|
| 249 |
-
|
| 250 |
-
[*Note 2*: Parameters with dependent types in which no
|
| 251 |
-
*template-parameter*s participate in template argument deduction, and
|
| 252 |
-
parameters that became non-dependent due to substitution of
|
| 253 |
-
explicitly-specified template arguments, will be checked during overload
|
| 254 |
-
resolution. — *end note*]
|
| 255 |
-
|
| 256 |
-
[*Example 9*:
|
| 257 |
-
|
| 258 |
-
``` cpp
|
| 259 |
-
template <class T> struct Z {
|
| 260 |
-
typedef typename T::x xx;
|
| 261 |
-
};
|
| 262 |
-
template <class T> typename Z<T>::xx f(void *, T); // #1
|
| 263 |
-
template <class T> void f(int, T); // #2
|
| 264 |
-
struct A {} a;
|
| 265 |
-
int main() {
|
| 266 |
-
f(1, a); // OK, deduction fails for #1 because there is no conversion from int to void*
|
| 267 |
-
}
|
| 268 |
-
```
|
| 269 |
-
|
| 270 |
-
— *end example*]
|
| 271 |
-
|
|
|
|
| 169 |
template <typename... T> struct X;
|
| 170 |
template <> struct X<> {};
|
| 171 |
template <typename T, typename... Ts>
|
| 172 |
struct X<T, Ts...> : X<Ts...> {};
|
| 173 |
struct D : X<int> {};
|
| 174 |
+
struct E : X<>, X<int> {};
|
| 175 |
|
| 176 |
template <typename... T>
|
| 177 |
int f(const X<T...>&);
|
| 178 |
int x = f(D()); // calls f<int>, not f<>
|
| 179 |
// B is X<>, C is X<int>
|
| 180 |
+
int z = f(E()); // calls f<int>, not f<>
|
| 181 |
```
|
| 182 |
|
| 183 |
— *end example*]
|
| 184 |
|
| 185 |
These alternatives are considered only if type deduction would otherwise
|
|
|
|
| 238 |
int i = f(1, g); // calls f(int, int (*)(int))
|
| 239 |
```
|
| 240 |
|
| 241 |
— *end example*]
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|