//Tpl.h
template<typename T>
void show(T){
}
// a translate unit
#include "Tpl.h"
void h(){
show(0); //implicitly instantiate specialization for show<int>
}
// b translate unit
#include "Tpl.h"
int main(){
show(0); //implicitly instantiate specialization for show<int>
}
According to rules in [temp.inst], there is a specialization for function template show in a and b translate unit respectively, that means there're two same specializations in a program.
However, the ODR rule does not mention this case.
basic.def.odr#6
There can be more than one definition of a class type, enumeration type, inline function with external linkage ([dcl.inline]), inline variable with external linkage ([dcl.inline]), class template, non-static function template, static data member of a class template, member function of a class template, or template specialization for which some template parameters are not specified ([temp.spec], [temp.class.spec]) in a program provided that each definition appears in a different translation unit, and provided the definitions satisfy the following requirements. Given such an entity named D defined in more than one translation unit, then
The case the rule listed are the following:
- class type
- enumeration type
- inline function or inline variable
- class template
- non-static function template
- static data member of a class template
- member function of a class template
- template specialization for which some template parameters are not specified
So, how about function template or static member function template ?
It also doesn't cover the case that exists more than one same specializations for a template in a program, the last item in the above list seems to refer to template partial specializations, So Is it a defect? Or there're other special rules applied to this case?