[temp.spec.partial.order]

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

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

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

#### 13.7.6.3 Partial ordering of partial specializations [temp.spec.partial.order]

[1](#1)

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

For two partial specializations,
the first is [*more specialized*](temp.deduct.partial#def:more_specialized "13.10.3.5 Deducing template arguments during partial ordering [temp.deduct.partial]") than the second if, given the following
rewrite to two function templates, the first function template is more
specialized than the second according to the [ordering rules for function
templates](temp.func.order "13.7.7.3 Partial ordering of function templates [temp.func.order]"):

- [(1.1)](#1.1)

  Each of the two
function templates has the same template parameters
and [associated constraints](temp.constr.decl#def:associated_constraints "13.5.3 Constrained declarations [temp.constr.decl]") as the corresponding partial specialization[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Each function template
has a single function parameter
whose type is a class template specialization where the template arguments
are the corresponding template parameters from the function template
for each template argument
in the [*template-argument-list*](temp.names#nt:template-argument-list "13.3 Names of template specializations [temp.names]") of the [*simple-template-id*](temp.names#nt:simple-template-id "13.3 Names of template specializations [temp.names]") of the partial specialization[.](#1.2.sentence-1)

[2](#2)

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

[*Example [1](#example-1)*: template<int I, int J, class T> class X { };template<int I, int J> class X<I, J, int> { }; // #1template<int I> class X<I, I, int> { }; // #2template<int I0, int J0> void f(X<I0, J0, int>); // Atemplate<int I0> void f(X<I0, I0, int>); // Btemplate <auto v> class Y { };template <auto* p> class Y<p> { }; // #3template <auto** pp> class Y<pp> { }; // #4template <auto* p0> void g(Y<p0>); // Ctemplate <auto** pp0> void g(Y<pp0>); // D

According to the ordering rules for function templates,
the function template*B* is more specialized than the function template*A* and
the function template*D* is more specialized than the function template*C*[.](#2.sentence-1)

Therefore, the partial specialization #2
is more specialized than the partial specialization #1
and the partial specialization #4
is more specialized than the partial specialization #3[.](#2.sentence-2)

â *end example*]

[*Example [2](#example-2)*: template<typename T> concept C = requires (T t) { t.f(); };template<typename T> concept D = C<T> && requires (T t) { t.f(); };

template<typename T> class S { };template<C T> class S<T> { }; // #1template<D T> class S<T> { }; // #2template<C T> void f(S<T>); // Atemplate<D T> void f(S<T>); // B

The partial specialization #2 is more specialized than #1
because B is more specialized than A[.](#2.sentence-3)

â *end example*]
