Does it matter .tpp or any other extension? And why not use .cpp?
It doesn’t matter what the extension is, but do not use .cpp because it is against the conventions (it will still work, but not do it; .cpp files are usually the source files). Also, this is a question of what your code base is using. For example, for this purpose I (and the Boost code base) use .ipp .
What is the meaning of the .tpp file?
Used when you do not want the file containing the module interface to contain all the details of the gory implementation. But you cannot write an implementation in a .cpp file because it is a template. This way you do your best (without considering explicit instances, etc.). for instance
Something.hpp
#pragma once namespace space { template <typename Type> class Something { public: void some_interface(); }; } // namespace space #include "Something.ipp"
Something.ipp
#pragma once namespace space { template <typename Type> void Something<Type>::some_interface() { // the implementation } } // namespace space
I thought the whole point of writing definitions in headers and implementations in a separate file is to save compilation time, so you only compile implementations once until you make some changes.
You cannot split a common code template into an implementation file. To use the template, you need the full code, so you need to put everything in the header file. For more details, see Why templates can only be implemented in the header file?
But if the implementation file has some kind of funky-looking file extension, how does it work in terms of compilation? How effective is it if the implementations were in cpp?
You will not compile .tpp , .ipp , -inl.h , etc. They are similar to header files, except that they are included only in other header files. You only compile source files ( .cpp , .cc ).