Is there a convention for what file extension is used for template class implementation? **.tpp .template .hpp **
To have all the information available, current compilers tend to require that a template must be fully defined whenever it is used. That includes all of its member functions and all template functions called from those. Consequently, template writers tend to place template definition in header files.
tpp file? It's used when you don't want the file that contains the interface of a module to contain all the gory implementation details. But you cannot write the implementation in a .cpp file because it's a template. So you do the best you can (not considering explicit instantiations and the like). For example.
2 file types use the . tcc file extension. TimeCalc Classic Data File. C++ Source Code File.
A class template is instantiated by passing a given set of types to it as template arguments. The C++ Standard Library contains many class templates, in particular the containers adapted from the Standard Template Library, such as vector .
"Is there a convention for what file extension is used for template class implementation?"
No there isn't really a standard convention established for these file extensions AFAIK.
There's a number of file extensions commonly used though, like
.icc
.inl
.tcc
(which seems at least to be used by my GCC 4.8.1 standard libraries implementation)...
It doesn't really matter that much, because you'll need to be explicit about it with the #include "MyImpl.tcc"
, #include "MyImpl.tpp"
statement in the template header file anyway.
You could use for instance .tci
(template class implementation, one I've invented creatively on the fly here ;-) )
One important point is, you should use a consistent naming strategy over all of your projects involved to the solution (This would make it even easier to set up you IDE preferences for syntax highlighting).
The only no go extensions IMHO are .cc
, .cpp
, .cxx
and .c
, which would confuse most of the automated build systems and IDE's currently around. The build system will assume these files need to be to build and linked as additional objects, and fail because of these either can't be build standalone, or ending up with multiple symbol definitions in linkage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With