This is the mail archive of the gcc@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]

Template instantiations


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 >>

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