AnthonyCalandra / modern-cpp-features

A cheatsheet of modern C++ language and library features.
MIT License
19.6k stars 2.08k forks source link

Improve constexpr section #78

Closed AnthonyCalandra closed 1 year ago

AnthonyCalandra commented 4 years ago

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.

AnthonyCalandra commented 1 year ago

https://github.com/AnthonyCalandra/modern-cpp-features/commit/0dd38f0badfd6c18f90fade6a9da438894a28e8b