From Jason Turner

[temp.class.spec.match]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0f4nw290/{from.md → to.md} +21 -3
tmp/tmp0f4nw290/{from.md → to.md} RENAMED
@@ -8,21 +8,23 @@ arguments of the class template specialization with the template
8
  argument lists of the partial specializations.
9
 
10
  - If exactly one matching specialization is found, the instantiation is
11
  generated from that specialization.
12
  - If more than one matching specialization is found, the partial order
13
- rules ([[temp.class.order]]) are used to determine whether one of the
14
  specializations is more specialized than the others. If none of the
15
  specializations is more specialized than all of the other matching
16
  specializations, then the use of the class template is ambiguous and
17
  the program is ill-formed.
18
  - If no matches are found, the instantiation is generated from the
19
  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
@@ -38,15 +40,31 @@ 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
 
 
8
  argument lists of the partial specializations.
9
 
10
  - If exactly one matching specialization is found, the instantiation is
11
  generated from that specialization.
12
  - If more than one matching specialization is found, the partial order
13
+ rules [[temp.class.order]] are used to determine whether one of the
14
  specializations is more specialized than the others. If none of the
15
  specializations is more specialized than all of the other matching
16
  specializations, then the use of the class template is ambiguous and
17
  the program is ill-formed.
18
  - If no matches are found, the instantiation is generated from the
19
  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]], and the deduced
24
+ template arguments satisfy the associated constraints of the partial
25
+ specialization, if any [[temp.constr.decl]].
26
 
27
  [*Example 1*:
28
 
29
  ``` cpp
30
  template<class T1, class T2, int I> class A { }; // #1
 
40
  A<int*, int*, 2> a5; // ambiguous: matches #3 and #5
41
  ```
42
 
43
  — *end example*]
44
 
45
+ [*Example 2*:
46
+
47
+ ``` cpp
48
+ template<typename T> concept C = requires (T t) { t.f(); };
49
+
50
+ template<typename T> struct S { }; // #1
51
+ template<C T> struct S<T> { }; // #2
52
+
53
+ struct Arg { void f(); };
54
+
55
+ S<int> s1; // uses #1; the constraints of #2 are not satisfied
56
+ S<Arg> s2; // uses #2; both constraints are satisfied but #2 is more specialized
57
+ ```
58
+
59
+ — *end example*]
60
+
61
  If the template arguments of a partial specialization cannot be deduced
62
  because of the structure of its *template-parameter-list* and the
63
  *template-id*, the program is ill-formed.
64
 
65
+ [*Example 3*:
66
 
67
  ``` cpp
68
  template <int I, int J> struct A {};
69
  template <int I> struct A<I+5, I*2> {}; // error
70