3 ms·
You 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 defini
by beojan 6y ago
You 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.