4 ms·
const pretty much does nothing to allow optimization in C/C++ :(
by brrrrrm 4y ago
const pretty much does nothing to allow optimization in C/C++ :(
- jcelerier 4y agoIt definitely does for globals
- tsimionescu 4y agoI think in general it does something for symbols visible outside the compilation unit (globals, public fields). Otherwise, the compiler usually has enough information to decide if something is actually a constant regardless of the const modifier.
- heinrich5991 4y ago`const` only does something for (global, static, local) variable declarations. The rest is just guidance to for the programmer. It doesn't do anything on pointers, and I think it doesn't do anything on members, but not entirely sure on the last one.