3 ms·
extern template was removed from the standard cause it wasn't implemented by any of the common compilers so you can't use it (unless you use Comeau which appear
by ender341341 3y ago
extern template was removed from the standard cause it wasn't implemented by any of the common compilers so you can't use it (unless you use Comeau which appears to be abandoned).
What it has to do with modules is you can effectively treat the module as a mini 'shared library' and when a template is instantiated you can append the compiled code into the module and re-use it in other compilation units.
- dataflow 3y agoNo, you're mixing up export and extern.
- ender341341 3y agoahh, your right, I do think with the rest of my comment it basically allows automating `extern template` though.
- dataflow 3y agoYou can't "append compiled code into a module" when templates can completely change the code that would've been compiled. This is C++, not Java. The only step that gets sped up for templates is their rudimentary parsing, which you trade off for the addition I/O of writing/reading the intermediate files in memory. Whether that small portion comes out ahead or not, it's dwarfed by the template instantiations the caller needs to do, which basically need to create the specialized AST nodes from scratch.
- ender341341 3y ago> You can't "append compiled code into a module" when templates can completely change the code that would've been compiled. Why can't you, I don't believe the standard says anything about the intermediary compiled unit of the module that would block it from doing so, I haven't dug into the implementations but I'd imagine they effectively create a static library analog of the compiled code and some analog of a header file for use in other compilation units, so say you're wanting to use std::vector<int> it can just look and see if that's already present in the module, if not instantiate it and then write it to the 'static library analog'