This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Template instantiations
- To: gcc at gcc dot gnu dot org
- Subject: Template instantiations
- From: Topi Maenpaa <topiolli at ees2 dot oulu dot fi>
- Date: Tue, 15 Aug 2000 10:52:16 +0300
- Organization: University of Oulu, Department of Electrical Engineering, Finland
Hi!
I have been wondering whether gcc can automatically merge equivalent
template instantiations. It may happen that one has a method (of
function, whatever) in a template class that does not make use of any of
the template parameters. It just provides some common functionality to
all of the template instances that might occur. In this case, the
instantiated template code will be the same in all cases. My question
is: can gcc detect this kind of situation, or does it emit new code even
though it might get duplicated? Is it even possible to do something like
this?
A simple example:
template <class T>
class A
{
private:
void init(void);
}
template <class T> void A::init(void)
{
//T is not used in this method, so the
//template instances will be equivalent.
}
--
-Topi-
<< http://ee.oulu.fi/~topiolli >>