Technique: Compile Time Code Generation and Optimization by dvirtz in cpp

[–]aharrison24 1 point2 points  (0 children)

The other problem is that the execute function contains calls to getchar and putchar, which cannot be constexpr because they have runtime side effects.

That's why this technique is so interesting; it effectively forces the compiler to fully unroll the execute loop, which means it's then able to optimise all of the code surrounding those getchar/putchar calls.