From Jason Turner

[temp.class.order]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp5y2s_77q/{from.md → to.md} +31 -19
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 at least as
4
- specialized as the second if, given the following rewrite to two
5
- function templates, the first function template is at least as
6
- specialized as the second according to the ordering rules for function
7
- templates ([[temp.func.order]]):
8
 
9
- - the first function template has the same template parameters as the
10
- first partial specialization and has a single function parameter whose
11
- type is a class template specialization with the template arguments of
12
- the first partial specialization, and
13
- - the second function template has the same template parameters as the
14
- second partial specialization and has a single function parameter
15
- whose type is a class template specialization with the template
16
- arguments of the second partial specialization.
 
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 I, int J> void f(X<I, J, int>); // A
24
- template<int I> void f(X<I, I, int>); // B
 
 
 
 
 
 
 
25
  ```
26
 
27
- The partial specialization `#2` is more specialized than the partial
28
- specialization `#1` because the function template `B` is more
29
- specialized than the function template `A` according to the ordering
30
- rules for function templates.
 
 
 
 
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