Suppose I have fileA.h
which declares a class classA
with template function SomeFunc<T>()
. This function is implemented directly in the header file (as is usual for template functions). Now I add a specialized implementation of SomeFunc()
(like for SomeFunc<int>()
) in fileA.C
(ie. not in the header file).
If I now call SomeFunc<int>()
from some other code (maybe also from another library), would it call the generic version, or the specialization?
I have this problem right now, where the class and function live in a library which is used by two applications. And one application correctly uses the specialization, while another app uses the generic form (which causes runtime problems later on). Why the difference? Could this be related to linker options etc? This is on Linux, with g++ 4.1.2.