In a large project we have a lot of classes (thousands), and for each of them a special smart pointer type is defined using typedef. This smart pointer type is a template class. When I compile with "gcc -Q" I see that a lot of time is spent compiling these smart pointers for each class. That is I see smartptr<class1>::methods, then smartptr<class2>::methods... smartptr<class2000>::methods
scrolling on the screen as gcc processes them.
Is there a trick to speedup this process? These classes are all the same from the smartptr point of view, no enable_if tricks, etc.
What I am trying right now:
- maybe make a non-template base class with few common methods
- use extern template class to reduce link symbols (and instantiation time? not sure yet)
But all of the above is not a complete solution. I wonder if there's another way to optimize compilation time, a trick to make gcc know that e.g. if it parsed smartptr once it could apply the same knowledge over and over again when seeing other specializations, because the generate code is the same.
Yes I know that it is not quite the same of course... But that's just a crazy idea.
Or maybe there're other tricks that I'm not aware of, that could speed up compilation. (Just to give the idea of what I'm talking, we could optimize another template by eliminating its static member data instantiation, which greatly reduced compilation time. This was not obvious at all.)