7 ms·
Parsing a single header file in isolation is cheap, but each header will include others, and templates mean many headers contain large amounts of code inline. F
by dbaupp 5y ago
Parsing a single header file in isolation is cheap, but each header will include others, and templates mean many headers contain large amounts of code inline. For instance, just including <vector> results in the compiler having to look at almost 30kloc, on my system:
$ clang -x c++ -E - <<<"#include <vector>" | wc -l
27378
Other headers are similar:
algorithm 23103
array 23450
memory 15909
random 52107
thread 31424
tuple 9240
(Of course, a bunch of this code is shared, e.g. including both thread and vector is “only” 35713 loc total, not 60kloc.)
I believe C++ compilers have SIMD-accelerated lexers/parsers because of the sheer explosion of code due to headers and templates.