C Template Metaprogramming Concepts πŸ†“ πŸ’Ž

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.

Uses a using alias or typedef to return a new type (e.g., removing a const qualifier). 3. SFINAE (Substitution Failure Is Not An Error) C Template Metaprogramming Concepts

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. The primary goal of TMP is

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) Instead, you use: Recursion: To mimic loops

Modern C++ (C++14/17/20) has shifted much of the "heavy lifting" from pure template syntax to constexpr and consteval functions. These allow you to write logic that looks like normal C++ but is guaranteed to run at compile time, significantly reducing the complexity of traditional template syntax. Why Use It?