tmp/tmp_83srkmo/{from.md → to.md}
RENAMED
|
@@ -23,22 +23,26 @@ g({1,2,3}); // error: no argument deduced for T
|
|
| 23 |
For a function parameter pack that occurs at the end of the
|
| 24 |
*parameter-declaration-list*, the type `A` of each remaining argument of
|
| 25 |
the call is compared with the type `P` of the *declarator-id* of the
|
| 26 |
function parameter pack. Each comparison deduces template arguments for
|
| 27 |
subsequent positions in the template parameter packs expanded by the
|
| 28 |
-
function parameter pack.
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
template<class ... Types> void f(Types& ...);
|
| 34 |
template<class T1, class ... Types> void g(T1, Types ...);
|
|
|
|
| 35 |
|
| 36 |
void h(int x, float& y) {
|
| 37 |
const int z = x;
|
| 38 |
f(x, y, z); // Types is deduced to int, float, const int
|
| 39 |
g(x, y, z); // T1 is deduced to int; Types is deduced to float, int
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
```
|
| 42 |
|
| 43 |
If `P` is not a reference type:
|
| 44 |
|
|
|
|
| 23 |
For a function parameter pack that occurs at the end of the
|
| 24 |
*parameter-declaration-list*, the type `A` of each remaining argument of
|
| 25 |
the call is compared with the type `P` of the *declarator-id* of the
|
| 26 |
function parameter pack. Each comparison deduces template arguments for
|
| 27 |
subsequent positions in the template parameter packs expanded by the
|
| 28 |
+
function parameter pack. When a function parameter pack appears in a
|
| 29 |
+
non-deduced context ([[temp.deduct.type]]), the type of that parameter
|
| 30 |
+
pack is never deduced.
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
template<class ... Types> void f(Types& ...);
|
| 34 |
template<class T1, class ... Types> void g(T1, Types ...);
|
| 35 |
+
template<class T1, class ... Types> void g1(Types ..., T1);
|
| 36 |
|
| 37 |
void h(int x, float& y) {
|
| 38 |
const int z = x;
|
| 39 |
f(x, y, z); // Types is deduced to int, float, const int
|
| 40 |
g(x, y, z); // T1 is deduced to int; Types is deduced to float, int
|
| 41 |
+
g1(x, y, z); // error: Types is not deduced
|
| 42 |
+
g1<int, int, int>(x, y, z); // OK, no deduction occurs
|
| 43 |
+
|
| 44 |
}
|
| 45 |
```
|
| 46 |
|
| 47 |
If `P` is not a reference type:
|
| 48 |
|