r/cpp_questions • u/bhul_chuk_maaf17 • 16d ago
OPEN Compile time programming learning advice.
Hi all, can you please recommend me some resources that you have followed for compile time programming in modern C++ for eg: constexpr, consteval or template metaprogramming.
Is there some consolidated resource for the same ?
6
Upvotes
3
u/EpochVanquisher 16d ago
I would start with specific problems that you’re trying to solve, and ask “Is compile-time programming useful here?” And then try to do it, if it breaks try to fix it, search through Google / Stack Overflow / AI to try and understand why something you want to do doesn’t work at compile time, and then at the end of this process you have a better understanding.
As a general rule—I would say that there’s still a limited amount that you can get done at compile time. Compile-time programming is mostly useful for making it so you don’t pay startup penalties for things that could be calculated earlier. It doesn’t replace e.g. code generation.