The ASM output will probably not be useful for beginners. It might be easier to think of the following example like having the expression square(2) replaced with the value 4 at compile-time.
int a = square(2);
Additionally, mention that constexpr doesn't imply that the expression is guaranteed to be evaluated at compile-time, rather, it makes it explicit that the compiler can do so.
The ASM output will probably not be useful for beginners. It might be easier to think of the following example like having the expression
square(2)
replaced with the value4
at compile-time.Additionally, mention that
constexpr
doesn't imply that the expression is guaranteed to be evaluated at compile-time, rather, it makes it explicit that the compiler can do so.