tmp/tmp5y2s_77q/{from.md → to.md}
RENAMED
|
@@ -1,31 +1,43 @@
|
|
| 1 |
#### Partial ordering of class template specializations <a id="temp.class.order">[[temp.class.order]]</a>
|
| 2 |
|
| 3 |
-
For two class template partial specializations, the first is
|
| 4 |
-
specialized
|
| 5 |
-
function templates, the first function template is
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
- the
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
the
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
template<int I, int J, class T> class X { };
|
| 20 |
template<int I, int J> class X<I, J, int> { }; // #1
|
| 21 |
template<int I> class X<I, I, int> { }; // #2
|
| 22 |
|
| 23 |
-
template<int
|
| 24 |
-
template<int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
```
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
|
|
|
| 1 |
#### Partial ordering of class template specializations <a id="temp.class.order">[[temp.class.order]]</a>
|
| 2 |
|
| 3 |
+
For two class template partial specializations, the first is *more
|
| 4 |
+
specialized* than the second if, given the following rewrite to two
|
| 5 |
+
function templates, the first function template is more specialized than
|
| 6 |
+
the second according to the ordering rules for function templates (
|
| 7 |
+
[[temp.func.order]]):
|
| 8 |
|
| 9 |
+
- Each of the two function templates has the same template parameters as
|
| 10 |
+
the corresponding partial specialization.
|
| 11 |
+
- Each function template has a single function parameter whose type is a
|
| 12 |
+
class template specialization where the template arguments are the
|
| 13 |
+
corresponding template parameters from the function template for each
|
| 14 |
+
template argument in the *template-argument-list* of the
|
| 15 |
+
*simple-template-id* of the partial specialization.
|
| 16 |
+
|
| 17 |
+
[*Example 1*:
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
template<int I, int J, class T> class X { };
|
| 21 |
template<int I, int J> class X<I, J, int> { }; // #1
|
| 22 |
template<int I> class X<I, I, int> { }; // #2
|
| 23 |
|
| 24 |
+
template<int I0, int J0> void f(X<I0, J0, int>); // A
|
| 25 |
+
template<int I0> void f(X<I0, I0, int>); // B
|
| 26 |
+
|
| 27 |
+
template <auto v> class Y { };
|
| 28 |
+
template <auto* p> class Y<p> { }; // #3
|
| 29 |
+
template <auto** pp> class Y<pp> { }; // #4
|
| 30 |
+
|
| 31 |
+
template <auto* p0> void g(Y<p0>); // C
|
| 32 |
+
template <auto** pp0> void g(Y<pp0>); // D
|
| 33 |
```
|
| 34 |
|
| 35 |
+
According to the ordering rules for function templates, the function
|
| 36 |
+
template *B* is more specialized than the function template *A* and the
|
| 37 |
+
function template *D* is more specialized than the function template
|
| 38 |
+
*C*. Therefore, the partial specialization \#2 is more specialized than
|
| 39 |
+
the partial specialization \#1 and the partial specialization \#4 is
|
| 40 |
+
more specialized than the partial specialization \#3.
|
| 41 |
+
|
| 42 |
+
— *end example*]
|
| 43 |
|