4 ms·
Constexpr improves compilation speed by the degree that it displaces template metaprogramming. Template metaprogramming runs at Python speed, where constexpr ru
by ncmncm 5y ago
Constexpr improves compilation speed by the degree that it displaces template metaprogramming. Template metaprogramming runs at Python speed, where constexpr runs orders of magnitude faster. Anywhere you have a choice between them, choose constexpr.
Substantial improvement in compilation speed might depend on use of JIT techniques, running generated code in the compiler to perform template evaluation. I.e., a template is not just a data structure, it is a compile-time function that, where used much, is compiled to optimized machine code, its run-time values being what we think of as types. Thus far, all these functions are run like an interpreter walking a syntax tree.
Precompiled headers, or module intermediate files, could have this code in them already optimized.