According to https://learn.microsoft.com/en-us/cpp/cpp/constexpr-cpp?view=vs-2019
"constexpr indicates that the value, or return value, is constant and, if possible, is computed at compile time."
Additionally, Difference between constexpr and static constexpr global variable
"On variable declarations, constexpr implies const, and a const variable at namespace scope has internal linkage by default (so adding static does not change anything)."
Which I think means that constexpr
implies const
which implies static
.
However, the answer for this question confuses me: When and why would you use static with constexpr?
It states that
- "constexpr variables are not compile-time values"
- "As it seems, we can benefit from static storage duration of a static constexpr variable in some corner cases."
What am I misunderstanding?