TMP — computations performed at compile time using templates.
Basic example:
1template <int N>2struct Factorial {3 static constexpr int value = N * Factorial<N - 1>::value;4};56template <>7struct Factorial<0> {8 static constexpr int value = 1;9};1011// Factorial<5>::value == 120
Type traits:
1constexpr bool is_int = std::is_integral_v<int>; // true2constexpr size_t size = sizeof(double); // 8
Modern alternatives:
constexpr if (C++17)std::integral_constant