From Jason Turner

[temp.class.spec.mfunc]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpk6g_96au/{from.md → to.md} +13 -7
tmp/tmpk6g_96au/{from.md → to.md} RENAMED
@@ -13,16 +13,19 @@ definitions of members of the primary template are never used as
13
  definitions for members of a class template partial specialization. An
14
  explicit specialization of a member of a class template partial
15
  specialization is declared in the same way as an explicit specialization
16
  of the primary template.
17
 
 
 
18
  ``` cpp
19
- // primary template
20
  template<class T, int I> struct A {
21
  void f();
22
  };
23
 
 
24
  template<class T, int I> void A<T,I>::f() { }
25
 
26
  // class template partial specialization
27
  template<class T> struct A<T,2> {
28
  void f();
@@ -38,19 +41,18 @@ template<> void A<char,2>::h() { }
38
 
39
  int main() {
40
  A<char,0> a0;
41
  A<char,2> a2;
42
  a0.f(); // OK, uses definition of primary template's member
43
- a2.g(); // OK, uses definition of
44
- // partial specialization's member
45
- a2.h(); // OK, uses definition of
46
- // explicit specialization's member
47
- a2.f(); // ill-formed, no definition of f for A<T,2>
48
- // the primary template is not used here
49
  }
50
  ```
51
 
 
 
52
  If a member template of a class template is partially specialized, the
53
  member template partial specializations are member templates of the
54
  enclosing class template; if the enclosing class template is
55
  instantiated ([[temp.inst]], [[temp.explicit]]), a declaration for
56
  every member template partial specialization is also instantiated as
@@ -62,10 +64,12 @@ specialization of the enclosing class template. If a partial
62
  specialization of the member template is explicitly specialized for a
63
  given (implicit) specialization of the enclosing class template, the
64
  primary member template and its other partial specializations are still
65
  considered for this specialization of the enclosing class template.
66
 
 
 
67
  ``` cpp
68
  template<class T> struct A {
69
  template<class T2> struct B {}; // #1
70
  template<class T2> struct B<T2*> {}; // #2
71
  };
@@ -75,5 +79,7 @@ template<> template<class T2> struct A<short>::B {}; // #3
75
  A<char>::B<int*> abcip; // uses #2
76
  A<short>::B<int*> absip; // uses #3
77
  A<char>::B<int> abci; // uses #1
78
  ```
79
 
 
 
 
13
  definitions for members of a class template partial specialization. An
14
  explicit specialization of a member of a class template partial
15
  specialization is declared in the same way as an explicit specialization
16
  of the primary template.
17
 
18
+ [*Example 1*:
19
+
20
  ``` cpp
21
+ // primary class template
22
  template<class T, int I> struct A {
23
  void f();
24
  };
25
 
26
+ // member of primary class template
27
  template<class T, int I> void A<T,I>::f() { }
28
 
29
  // class template partial specialization
30
  template<class T> struct A<T,2> {
31
  void f();
 
41
 
42
  int main() {
43
  A<char,0> a0;
44
  A<char,2> a2;
45
  a0.f(); // OK, uses definition of primary template's member
46
+ a2.g(); // OK, uses definition of partial specialization's member
47
+ a2.h(); // OK, uses definition of explicit specialization's member
48
+ a2.f(); // ill-formed, no definition of f for A<T,2>; the primary template is not used here
 
 
 
49
  }
50
  ```
51
 
52
+ — *end example*]
53
+
54
  If a member template of a class template is partially specialized, the
55
  member template partial specializations are member templates of the
56
  enclosing class template; if the enclosing class template is
57
  instantiated ([[temp.inst]], [[temp.explicit]]), a declaration for
58
  every member template partial specialization is also instantiated as
 
64
  specialization of the member template is explicitly specialized for a
65
  given (implicit) specialization of the enclosing class template, the
66
  primary member template and its other partial specializations are still
67
  considered for this specialization of the enclosing class template.
68
 
69
+ [*Example 2*:
70
+
71
  ``` cpp
72
  template<class T> struct A {
73
  template<class T2> struct B {}; // #1
74
  template<class T2> struct B<T2*> {}; // #2
75
  };
 
79
  A<char>::B<int*> abcip; // uses #2
80
  A<short>::B<int*> absip; // uses #3
81
  A<char>::B<int> abci; // uses #1
82
  ```
83
 
84
+ — *end example*]
85
+