3 ms·
I think "template specializations" might have been the wrong term, and what was meant was "template implementations".
by beojan 6y ago
I think "template specializations" might have been the wrong term, and what was meant was "template implementations".
- MaxBarraclough 6y agoPerhaps I'm missing something I still don't see why you'd ever #include a .cpp file from a .hpp header file.
- beojan 6y agoYou can't separately compile and link in templates. The compiler needs to see the definition to instantiate it. Meanwhile you might not want to put that definition in the header file so the header just contains the interface. Ergo you #include the implementation at the bottom of the header file.
- MaxBarraclough 6y agoThat isn't an 'implementation file' in the relevant sense. If the file is intended to be used with #include, it's a header file, and should be given the .h or .hpp extension. If the file corresponds to an object file in the build, it should be given the .cpp extension (or .cxx). If you want to break apart your template metaprogramming into several .hpp files, you can do so.