Large templated projects are slow to compile, the STL being a main culprit of this it seems from empiric evidence. But, why is it slow to compile?
I’ve optimized builds before by watching for header includes and by combining compilation units, but I don’t get why template libraries are quite so slow to compile.
Templated code has to be taken as another language to generate C++ code.
In this way of thinking, templated code has to be parsed, executed, then the compiler can generate C++ code that has to be added to the current unit file, and then we can compile the whole C++ code.
I’ve heard that not all compilers do this exactly but that’s the main idea, and that suppose that there is a lot more happening before really compiling the code as some of the code has to be generated first.