5 ms·
In C++ you can’t really even separate them if you want to define templates, because (unless I am mistaken) template instantiation can only be done at compile ti
by joppy 5y ago
In C++ you can’t really even separate them if you want to define templates, because (unless I am mistaken) template instantiation can only be done at compile time rather than link time. It’s sad to not be able to cleanly separate the interface from the implementation.
- zetalyrae 5y agoYes, I think the module interface file should be for the user rather than the compiler. The compiler would parse both the module interface and module body files, merge them and check for consistency, and produce both an object code file for the code in that module and a binary module interface that contains an efficiently serialized form of the interface, the bodies of generic functions, and maybe the table of monomorphic instances for separate compilation. Then the build system makes sure to import the relevant binary interface files when building a project.
- pjmlp 5y agoJust like C++20 modules allow. You only need to export the public parts of the templates.
- bboreham 5y agoIf my memory isn’t failing me, the Sun C++ compiler I used in 1994 did template expansion and compilation at link-time. However it was rather annoying in use, having to wait a long time to get errors arising from instantiation.
- pjmlp 5y agoYou can now when using C++20 modules.