I have a lot of template code. Since bad template code does not throw a compiler error unless it is compiled, is there any way I can check which template functions the compiler actually 'compiled' and which were ignored altogether?
EDIT 2:
If a particular class template or function template is instantiated once, for any parameter types, then that is OK. I want the list of function/class templates that were never instantiated in any form.
One particular example is the following. They are two distinct template functions, and I would like to know if either or both is never instantiated.
template <typename T_InputItr, typename T_Distance>
void advance( T_InputItr& aItr, T_Distance aN, bidirectional_iterator_tag )
template <typename T_InputItr, typename T_Distance>
void advance( T_InputItr& aItr, T_Distance aN, random_access_iterator_tag )
EDIT: Currently, for classes, I instantiate them in the .cpp
file manually like this:
template TClass<int>;
for all the types I am interested in. That's well and good. But that is if I remember to do that. Sometimes I need to write a lot of small template classes/functions where I forget to instantiate some of the function/class templates manually and find out later down the road. I would like the compiler to tell me that.
Alternatively, if I could get the list of function/class templates that were instantiated (for any parameter), then I could compare that to the full list which I might grep for in the code.
Another benefit would be to 'test' which methods were compiled in a template class that uses type traits to selectively compile out certain functions. I want to be certain my logic for selecting the correct functions is correct before moving on.