PDA

View Full Version : explicit specialization of methods of a template class in several .so



tlknv
06-21-2011, 08:24 AM
Hi All,
I need a confirmation that what I do is perfectly correct and I need to learn documents that confirm that.
I have a template class (
template <class T> class C) which is defined in the shared library "a". Some of the methods of the class C are specialized/defined explicitly for some particular type TT in the same shared library "a" and an object of
C<TT> is constructed in this library as well. One method ( ex:
void C::f() ) is not specialized explicitly for type TT in library "a" but specialized in another shared library "b". Just in case: C<T>::f() has some compilable definition for any type T, ex:
template<class T> void C<T>::f(){} in library "a".
Library "b" is not always linked to "a". If it's not linked the default
C<T>::f() is called (which does nothing).
If "b" is linked to "a" then explicitly specialized
C<TT>::f() which resides in "b" is called. This is what I expect.
Is it standard behavior? Is it documented somewhere? Where?
I'm using gcc under linux and the code is compiled for FreeBSD.

Thanks,
Boris

Fordy
06-21-2011, 08:39 AM
Please dont cross post

http://cboard.cprogramming.com/cplusplus-programming/139022-explicit-specialization-methods-template-class-several-so.html

C (http://cboard.cprogramming.com/cplusplus-programming/139022-explicit-specialization-methods-template-class-several-so.html)LOSED