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.
C++ in general is slow to compile because of the ancient include mechanism, which causes the compiler to recursively re-parse every header with all its declarations and definitions and all that's included for every translation unit.
Templates just build on that "feature". But they require all code to be in headers, too, forcing the compiler to also re-parse all implementations of all templates included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With