Answer
constexpr marks an entity for use in constant evaluation when its requirements are satisfied. • A constexpr variable must be initialized by a constant expression. • A constexpr function can also execute at runtime when called with runtime values. • Constant evaluation rejects operations that are not permitted in a constant expression.
💡 C++ Example
constexpr int square(int value) {
return value * value;
}
static_assert(square(5) == 25);
⚡ Quick Revision
constexpr enables constant evaluation but does not force every function call to compile time.