Pretty sure I know the answer to this already, but it's worth it.
So, let's say I have a list of types:
template <typename ...Ts> struct typelist{};
This contains some objects:
struct foo{}; struct bar{}; struct quux{}; using objects = typelist<foo, bar, quux>;
Now I have a template class ( baz ) that can accept any of these objects. But, due to the size of the code and compilation time, I want to have an implementation of my template method in the cpp file.
So, at the bottom of baz.cpp I have:
template <> class baz<foo>; template <> class baz<bar>; template <> class baz<quux>;
The problem is that I have many classes, such as baz , and the list of objects they work with is also constantly changing. So ... anyway, can I save my only list of objects and use it in the cpp file of each baz object for specialization? Then all I need to do is update my list when I have a new object and all the object files are restored.
c ++ templates metaprogramming template-specialization
Sam kellett
source share