This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: template specialization instantiation problem
- To: Nathan Sidwell <nathan at cs dot bris dot ac dot uk>
- Subject: Re: template specialization instantiation problem
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 30 Jun 1998 00:47:45 -0300
- Cc: egcs-bugs at cygnus dot com
- References: <35976FB0.1413@cs.bris.ac.uk>
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