Question.4
A constexpr function is called with a runtime variable:
constexpr int square(int x) { return x * x; } int sensor_val = read_adc(); int result = square(sensor_val);
What happens?
Select Answer
Compilation error -- constexpr functions cannot accept runtime arguments
constexpr
The function executes at runtime as a normal function -- constexpr functions can run at runtime when arguments are not constant
The compiler forces sensor_val to be evaluated at compile time
sensor_val
Undefined behavior -- mixing constexpr with runtime data