The compiler determines whether to use the primary template or one of its
partial specializations by matching the template arguments of the class
template specialization with the template argument lists of the primary
template and the partial specializations:
- If the compiler finds only one specialization, then the compiler generates
a definition from that specialization.
- If the compiler finds more than one specialization, then the compiler
tries to determine which of the specializations is the most
specialized. A template X is more specialized than a
template Y if every argument list that matches the one specified by
X also matches the one specified by Y, but not the other
way around. If the compiler cannot find the most specialized
specialization, then the use of the class template is ambiguous; the
compiler will not allow the program.
- If the compiler does not find any matches, then the compiler generates a
definition from the primary template.
Related References
