1 minute read

There is this in-depth blog post going over consteval, constexpr, and runtime functions.

consteval functions are evaluated only at compile-time.

constexpr functions can be evaluated at compile- or runtime.

Main point of the post: They can all call each other as long as the taken code path (branch) fits the call type.

Side notes to keep in mind:

  • The C++23 feature if consteval can be especially useful for constexpr functions.
  • constexpr functions can be implemented s.t. they are only callable either at compile-time XOR runtime. This is considered bad practice.
  • C++23 Foot Gun: A templated constexpr function can be implicitly converted to a consteval function (Escalation).