The difference between constexpr and C++20 consteval:
constexpr: Function can be evaluated at compile-time if arguments are constant expressions, but can also run at runtime if given runtime variables.consteval(Immediate Function): Function must evaluate at compile-time. If called with runtime variables, the compiler produces a hard compilation error!
consteval int ComputeLookupTable(int index) {
return index * index + 37;
}
constexpr int val = ComputeLookupTable(5); // Evaluated directly in compiler frontend!