[temp.spec.partial.member]

# 13 Templates [[temp]](./#temp)

## 13.7 Template declarations [[temp.decls]](temp.decls#temp.spec.partial.member)

### 13.7.6 Partial specialization [[temp.spec.partial]](temp.spec.partial#member)

#### 13.7.6.4 Members of class template partial specializations [temp.spec.partial.member]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L3973)

The members of the class template partial specialization are
unrelated to the members of the primary template[.](#1.sentence-1)

Class template partial specialization members that are used in a way that
requires a definition shall be defined; the definitions of members of the
primary template are never used as definitions for members of a class
template partial specialization[.](#1.sentence-2)

An explicit specialization of a member of a class template partial
specialization is declared in the same way as an explicit specialization of
a member of the primary template[.](#1.sentence-3)

[*Example [1](#example-1)*: // primary class templatetemplate<class T, int I> struct A {void f();};

// member of primary class templatetemplate<class T, int I> void A<T,I>::f() { }// class template partial specializationtemplate<class T> struct A<T,2> {void f(); void g(); void h();};

// member of class template partial specializationtemplate<class T> void A<T,2>::g() { }// explicit specializationtemplate<> void A<char,2>::h() { }int main() { A<char,0> a0;
 A<char,2> a2;
 a0.f(); // OK, uses definition of primary template's member a2.g(); // OK, uses definition of partial specialization's member a2.h(); // OK, uses definition of explicit specialization's member a2.f(); // error: no definition of f for A<T,2>; the primary template is not used here} â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L4017)

If a member template of a class template is partially specialized,
the member template partial specializations are member templates of
the enclosing class template;
if the enclosing class template is instantiated ([[temp.inst]](temp.inst "13.9.2 Implicit instantiation"), [[temp.explicit]](temp.explicit "13.9.3 Explicit instantiation")),
a declaration for every member template partial specialization is also
instantiated as part of creating the members of the class template
specialization[.](#2.sentence-1)

If the primary member template is explicitly specialized for a given
(implicit) specialization of the enclosing class template,
the partial specializations of the member template are ignored for this
specialization of the enclosing class template[.](#2.sentence-2)

If a partial specialization of the member template is explicitly specialized
for a given (implicit) specialization of the enclosing class template,
the primary member template and its other partial specializations are
still considered for this specialization of the enclosing class template[.](#2.sentence-3)

[*Example [2](#example-2)*: template<class T> struct A {template<class T2> struct B {}; // #1template<class T2> struct B<T2*> {}; // #2};

template<> template<class T2> struct A<short>::B {}; // #3 A<char>::B<int*> abcip; // uses #2 A<short>::B<int*> absip; // uses #3 A<char>::B<int> abci; // uses #1 â *end example*]
