logoalt Hacker News

fookeryesterday at 8:15 PM4 repliesview on HN

C++ templates and metaprogramming is fundamentally incompatible with the idea of your code being treated in modules.

The current solution chosen by compilers is to basically have a copy of your code for every dependency that wants to specialize something.

For template heavy code, this is a combinatorial explosion.


Replies

WalterBrightyesterday at 8:36 PM

D has best-in-class templates and metaprogramming, and modules. It works fine.

amlutoyesterday at 9:57 PM

I think that SFINAE and, to a lesser extent, concepts is fundamentally a bit odd when multiple translation units are involved, but otherwise I don’t see the problem.

It’s regrettable that the question of whether a type meets the requirements to call some overload or to branch in a particular if constexpr expression, etc, can depend on what else is in scope.

show 1 reply
direwolf20yesterday at 11:48 PM

The compiler is supposed to put the template IR into the compiled module file, isn't it?

show 1 reply
pjmlpyesterday at 8:25 PM

It has worked perfectly fine while using VC++, minus the usual ICE that still come up.

show 1 reply