C++: Difference between revisions
| Line 463: | Line 463: | ||
===const=== | ===const=== | ||
For variables: | For variables: | ||
# Use <code>constexpr</code> for values initialized at compile time and won't change at runtime. Most of the time, this is what you want for hardcoded compile time parameters. | |||
# Use <code>const</code> for values initialized at runtime and won't change. | # Use <code>const</code> for values initialized at runtime and won't change. | ||
# Use <code> | # Use <code>constinit</code> for values initialized at compile time and may change at runtime. I haven't found a use case for this yet. | ||
For functions: | For functions: | ||