This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: template specialization instantiation problem


Nathan Sidwell <nathan@cs.bris.ac.uk> writes:

> I have a template class, let's call it Template<T>, and for some
> particular T, I specialize a member function.

> What I would expect is that the specialization Template<int>::func is
> only emitted when I explicitly instantiate Template<int>.

Your expectation is correct, egcs should not have generated a
definition for that template function specialization when it is not
even used.

You may temporarily work around this problem by just declaring the
template member function specialization in a global header-file, and
defining and explicitly instantiating the template function in a
single source file.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]