Uses static constexpr to return a result (e.g., calculating a factorial at compile time).
The primary goal of TMP is . By moving logic to the compilation phase, the final executable is smaller and faster because the work has already been done by the compiler before the user ever runs the program. C Template Metaprogramming Concepts
Introduced heavily in , these are standard metafunctions used to query properties of types. They allow your code to ask questions like: "Is this type a pointer?" ( std::is_pointer ) "Are these two types the same?" ( std::is_same ) "Can I add these two types together?" 5. Concepts (C++20) Uses static constexpr to return a result (e
TMP is a purely sub-language. Because the compiler cannot "change" a value once it is defined during a build, you don't use loops or variables. Instead, you use: Recursion: To mimic loops. Introduced heavily in , these are standard metafunctions