#compile-time
6 posts tagged #compile-time.
Parsing your config file before the program exists
#embed puts a file into the translation unit and reflection enumerates a struct's fields. Together they turn a configuration file into a compile-time constant, with the keys derived from the struct rather than written twice, and a missing entry becoming a build error rather than a failed startup.
C++26 lets you throw and catch at compile time
Until now a throw inside a constant expression was an immediate compile error, which forced constexpr code to report failure some other way. C++26 allows exceptions during constant evaluation: a throw that gets caught in the same evaluation is fine, and only an uncaught one fails the build. GCC 16.1 runs it today.
What compile-time regex costs, measured
Moving work to compile time moves the bill there too. Including the CTRE header costs about three quarters of a second, and each distinct pattern adds to that. The library also declines some PCRE syntax and reports it through an error message that names the offset while wrapping it in template noise.
Validating a string before the program exists
CTRE matches run inside constant expressions, so a regex can check and parse a string literal while the compiler is still working. A malformed version string then stops the build rather than surviving into production, and the parsed result is available as a constant.
C++ modules in 2026: import std works, import boost is coming, your IDE still can't
import std compiles on GCC 16.1, Clang 18+, and MSVC. Boost has a per-library module prototype showing 45% build-time reductions. But CMake support is still experimental, clangd needs a full rebuild on module changes, IntelliSense has been 'experimental' for seven years, and almost no libraries ship module definitions. For reflection users: PCH is faster than modules on GCC 16.1 today.
The hidden cost of <meta> -- and the three-line fix
Vittorio Romeo measured what C++26 reflection actually costs: the <meta> header adds ~181ms per TU on GCC 16.1, but the reflection algorithm itself is ~0.07ms per enumerator. The header is 2500x more expensive than the logic. A three-line CMake PCH stanza cuts the header cost by 2.3x. Modules, surprisingly, make it worse.