From Jason Turner

[temp.class.spec.mfunc]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptk2zb3ug/{from.md → to.md} +0 -85
tmp/tmptk2zb3ug/{from.md → to.md} RENAMED
@@ -1,85 +0,0 @@
1
- #### Members of class template specializations <a id="temp.class.spec.mfunc">[[temp.class.spec.mfunc]]</a>
2
-
3
- The template parameter list of a member of a class template partial
4
- specialization shall match the template parameter list of the class
5
- template partial specialization. The template argument list of a member
6
- of a class template partial specialization shall match the template
7
- argument list of the class template partial specialization. A class
8
- template partial specialization is a distinct template. The members of
9
- the class template partial specialization are unrelated to the members
10
- of the primary template. Class template partial specialization members
11
- that are used in a way that requires a definition shall be defined; the
12
- 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
- [*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();
32
- void g();
33
- void h();
34
- };
35
-
36
- // member of class template partial specialization
37
- template<class T> void A<T,2>::g() { }
38
-
39
- // explicit specialization
40
- template<> void A<char,2>::h() { }
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(); // error: 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
59
- part of creating the members of the class template specialization. If
60
- the primary member template is explicitly specialized for a given
61
- (implicit) specialization of the enclosing class template, the partial
62
- specializations of the member template are ignored for this
63
- specialization of the enclosing class template. If a partial
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
- };
76
-
77
- template<> template<class T2> struct A<short>::B {}; // #3
78
-
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
-