tmp/tmpqotd4tt5/{from.md → to.md}
RENAMED
|
@@ -20,21 +20,45 @@ argument lists of the partial specializations.
|
|
| 20 |
|
| 21 |
A partial specialization matches a given actual template argument list
|
| 22 |
if the template arguments of the partial specialization can be deduced
|
| 23 |
from the actual template argument list ([[temp.deduct]]).
|
| 24 |
|
|
|
|
|
|
|
| 25 |
``` cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
A<int, int, 1> a1; // uses #1
|
| 27 |
A<int, int*, 1> a2; // uses #2, T is int, I is 1
|
| 28 |
A<int, char*, 5> a3; // uses #4, T is char
|
| 29 |
A<int, char*, 1> a4; // uses #5, T1 is int, T2 is char, I is 1
|
| 30 |
A<int*, int*, 2> a5; // ambiguous: matches #3 and #5
|
| 31 |
```
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
In a type name that refers to a class template specialization, (e.g.,
|
| 38 |
`A<int, int, 1>`) the argument list shall match the template parameter
|
| 39 |
list of the primary template. The template arguments of a specialization
|
| 40 |
are deduced from the arguments of the primary template.
|
|
|
|
| 20 |
|
| 21 |
A partial specialization matches a given actual template argument list
|
| 22 |
if the template arguments of the partial specialization can be deduced
|
| 23 |
from the actual template argument list ([[temp.deduct]]).
|
| 24 |
|
| 25 |
+
[*Example 1*:
|
| 26 |
+
|
| 27 |
``` cpp
|
| 28 |
+
template<class T1, class T2, int I> class A { }; // #1
|
| 29 |
+
template<class T, int I> class A<T, T*, I> { }; // #2
|
| 30 |
+
template<class T1, class T2, int I> class A<T1*, T2, I> { }; // #3
|
| 31 |
+
template<class T> class A<int, T*, 5> { }; // #4
|
| 32 |
+
template<class T1, class T2, int I> class A<T1, T2*, I> { }; // #5
|
| 33 |
+
|
| 34 |
A<int, int, 1> a1; // uses #1
|
| 35 |
A<int, int*, 1> a2; // uses #2, T is int, I is 1
|
| 36 |
A<int, char*, 5> a3; // uses #4, T is char
|
| 37 |
A<int, char*, 1> a4; // uses #5, T1 is int, T2 is char, I is 1
|
| 38 |
A<int*, int*, 2> a5; // ambiguous: matches #3 and #5
|
| 39 |
```
|
| 40 |
|
| 41 |
+
— *end example*]
|
| 42 |
+
|
| 43 |
+
If the template arguments of a partial specialization cannot be deduced
|
| 44 |
+
because of the structure of its *template-parameter-list* and the
|
| 45 |
+
*template-id*, the program is ill-formed.
|
| 46 |
+
|
| 47 |
+
[*Example 2*:
|
| 48 |
+
|
| 49 |
+
``` cpp
|
| 50 |
+
template <int I, int J> struct A {};
|
| 51 |
+
template <int I> struct A<I+5, I*2> {}; // error
|
| 52 |
+
|
| 53 |
+
template <int I> struct A<I, I> {}; // OK
|
| 54 |
+
|
| 55 |
+
template <int I, int J, int K> struct B {};
|
| 56 |
+
template <int I> struct B<I, I*2, 2> {}; // OK
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
— *end example*]
|
| 60 |
|
| 61 |
In a type name that refers to a class template specialization, (e.g.,
|
| 62 |
`A<int, int, 1>`) the argument list shall match the template parameter
|
| 63 |
list of the primary template. The template arguments of a specialization
|
| 64 |
are deduced from the arguments of the primary template.
|