linker then tries to resolve everything, but can re-invoke the compiler as needed |
Ok.
You had translation units without template implementations.
They did produce object code that has function calls.
Will a call of templated function differ from regular function call,
i.e. can you tell which should link to other object files/libraries
and which need template instantiation?
What if some translation unit already has some explicitly instantiated templates? Can it?
Which files would the linker seek in order to compile templates?
It is still hazy to me how the linker dances around the ODR with the current template model.
You either have template definitions the header, or include them. The header file (declaration) should include the template definitions, for you cannot expect the user to include all necessary files.
IDE/cmake/qmake/etc can define a "project" from existing files. Perhaps auto-include all code files from a tree. Each source file leads implicitly to a translation unit. Therefore, you should not name your template definitions ".cpp", or any other suffix that the system takes as a source file.
You probably want to differentiate "regular" headers from the template definitions too, yet keep the name as a "header type" so that your IDE can do whatever fancy things IDEs do with C++ files.