Why is comparing two parameters of a constexpr function not a constant condition for static assertion?

A constexpr function can also be invoked with arguments evaluated at run-time (in that case, it just gets executed just like any regular function). See, for instance, this live example.

A static_assert(), on the other hand, strictly requires its condition to be a constant expression that can be evaluated at compile time.

Leave a Comment