tmp/tmpohvzgwp8/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Partial ordering of partial specializations <a id="temp.spec.partial.order">[[temp.spec.partial.order]]</a>
|
| 2 |
+
|
| 3 |
+
For two partial specializations, the first is *more specialized* than
|
| 4 |
+
the second if, given the following rewrite to two function templates,
|
| 5 |
+
the first function template is more specialized than the second
|
| 6 |
+
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
|
| 10 |
+
and associated constraints [[temp.constr.decl]] as the corresponding
|
| 11 |
+
partial specialization.
|
| 12 |
+
- Each function template has a single function parameter whose type is a
|
| 13 |
+
class template specialization where the template arguments are the
|
| 14 |
+
corresponding template parameters from the function template for each
|
| 15 |
+
template argument in the *template-argument-list* of the
|
| 16 |
+
*simple-template-id* of the partial specialization.
|
| 17 |
+
|
| 18 |
+
[*Example 1*:
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
template<int I, int J, class T> class X { };
|
| 22 |
+
template<int I, int J> class X<I, J, int> { }; // #1
|
| 23 |
+
template<int I> class X<I, I, int> { }; // #2
|
| 24 |
+
|
| 25 |
+
template<int I0, int J0> void f(X<I0, J0, int>); // A
|
| 26 |
+
template<int I0> void f(X<I0, I0, int>); // B
|
| 27 |
+
|
| 28 |
+
template <auto v> class Y { };
|
| 29 |
+
template <auto* p> class Y<p> { }; // #3
|
| 30 |
+
template <auto** pp> class Y<pp> { }; // #4
|
| 31 |
+
|
| 32 |
+
template <auto* p0> void g(Y<p0>); // C
|
| 33 |
+
template <auto** pp0> void g(Y<pp0>); // D
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
According to the ordering rules for function templates, the function
|
| 37 |
+
template *B* is more specialized than the function template *A* and the
|
| 38 |
+
function template *D* is more specialized than the function template
|
| 39 |
+
*C*. Therefore, the partial specialization \#2 is more specialized than
|
| 40 |
+
the partial specialization \#1 and the partial specialization \#4 is
|
| 41 |
+
more specialized than the partial specialization \#3.
|
| 42 |
+
|
| 43 |
+
— *end example*]
|
| 44 |
+
|
| 45 |
+
[*Example 2*:
|
| 46 |
+
|
| 47 |
+
``` cpp
|
| 48 |
+
template<typename T> concept C = requires (T t) { t.f(); };
|
| 49 |
+
template<typename T> concept D = C<T> && requires (T t) { t.f(); };
|
| 50 |
+
|
| 51 |
+
template<typename T> class S { };
|
| 52 |
+
template<C T> class S<T> { }; // #1
|
| 53 |
+
template<D T> class S<T> { }; // #2
|
| 54 |
+
|
| 55 |
+
template<C T> void f(S<T>); // A
|
| 56 |
+
template<D T> void f(S<T>); // B
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
The partial specialization \#2 is more specialized than \#1 because `B`
|
| 60 |
+
is more specialized than `A`.
|
| 61 |
+
|
| 62 |
+
— *end example*]
|
| 63 |
+
|