tmp/tmpz5z1wlp3/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Members of class template partial specializations <a id="temp.spec.partial.member">[[temp.spec.partial.member]]</a>
|
| 2 |
+
|
| 3 |
+
The members of the class template partial specialization are unrelated
|
| 4 |
+
to the members of the primary template. Class template partial
|
| 5 |
+
specialization members that are used in a way that requires a definition
|
| 6 |
+
shall be defined; the definitions of members of the primary template are
|
| 7 |
+
never used as definitions for members of a class template partial
|
| 8 |
+
specialization. An explicit specialization of a member of a class
|
| 9 |
+
template partial specialization is declared in the same way as an
|
| 10 |
+
explicit specialization of a member of the primary template.
|
| 11 |
+
|
| 12 |
+
[*Example 1*:
|
| 13 |
+
|
| 14 |
+
``` cpp
|
| 15 |
+
// primary class template
|
| 16 |
+
template<class T, int I> struct A {
|
| 17 |
+
void f();
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
// member of primary class template
|
| 21 |
+
template<class T, int I> void A<T,I>::f() { }
|
| 22 |
+
|
| 23 |
+
// class template partial specialization
|
| 24 |
+
template<class T> struct A<T,2> {
|
| 25 |
+
void f();
|
| 26 |
+
void g();
|
| 27 |
+
void h();
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
// member of class template partial specialization
|
| 31 |
+
template<class T> void A<T,2>::g() { }
|
| 32 |
+
|
| 33 |
+
// explicit specialization
|
| 34 |
+
template<> void A<char,2>::h() { }
|
| 35 |
+
|
| 36 |
+
int main() {
|
| 37 |
+
A<char,0> a0;
|
| 38 |
+
A<char,2> a2;
|
| 39 |
+
a0.f(); // OK, uses definition of primary template's member
|
| 40 |
+
a2.g(); // OK, uses definition of partial specialization's member
|
| 41 |
+
a2.h(); // OK, uses definition of explicit specialization's member
|
| 42 |
+
a2.f(); // error: no definition of f for A<T,2>; the primary template is not used here
|
| 43 |
+
}
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
— *end example*]
|
| 47 |
+
|
| 48 |
+
If a member template of a class template is partially specialized, the
|
| 49 |
+
member template partial specializations are member templates of the
|
| 50 |
+
enclosing class template; if the enclosing class template is
|
| 51 |
+
instantiated [[temp.inst]], [[temp.explicit]], a declaration for every
|
| 52 |
+
member template partial specialization is also instantiated as part of
|
| 53 |
+
creating the members of the class template specialization. If the
|
| 54 |
+
primary member template is explicitly specialized for a given (implicit)
|
| 55 |
+
specialization of the enclosing class template, the partial
|
| 56 |
+
specializations of the member template are ignored for this
|
| 57 |
+
specialization of the enclosing class template. If a partial
|
| 58 |
+
specialization of the member template is explicitly specialized for a
|
| 59 |
+
given (implicit) specialization of the enclosing class template, the
|
| 60 |
+
primary member template and its other partial specializations are still
|
| 61 |
+
considered for this specialization of the enclosing class template.
|
| 62 |
+
|
| 63 |
+
[*Example 2*:
|
| 64 |
+
|
| 65 |
+
``` cpp
|
| 66 |
+
template<class T> struct A {
|
| 67 |
+
template<class T2> struct B {}; // #1
|
| 68 |
+
template<class T2> struct B<T2*> {}; // #2
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
template<> template<class T2> struct A<short>::B {}; // #3
|
| 72 |
+
|
| 73 |
+
A<char>::B<int*> abcip; // uses #2
|
| 74 |
+
A<short>::B<int*> absip; // uses #3
|
| 75 |
+
A<char>::B<int> abci; // uses #1
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
— *end example*]
|
| 79 |
+
|