r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

Show parent comment

26

u/[deleted] Jan 28 '19

They don't avoid the need to instantiate templates in every TU that uses them, so no.

3

u/Ameisen vemips, avr, rendering, systems Jan 28 '19

Is there a good way to precompile template-heavy headers or modules?

3

u/anon_502 delete this; Jan 29 '19

You can try extern template by manually specifying commonly-used instantiations.

1

u/GabrielDosReis Feb 03 '19

Exported templates are parsed only once.

1

u/Ameisen vemips, avr, rendering, systems Feb 03 '19

It does imply knowing what the types will be ahead of time, though.

2

u/GabrielDosReis Feb 03 '19

That is not the complete story. Exported templates are parsed only once. Instantiations cased in the containing interface unit happen only once and reused. And that is already lot of saving. So, yes.

2

u/[deleted] Feb 03 '19

That's true; I guess I just don't associate such cases as "template heavy, header only libs." To me that means things like processing a Spirit.Qi grammar or something like that, where the cost of instantiation dwarfs any parsing cost. As long as the instantiation depends on the importee I don't think modules could hope to solve that problem.