4 ms·
And event const can't in general be used for optimizations (because there can be another reference to the same location, or one can just const_cast)
by varajelle 4y ago
And event const can't in general be used for optimizations (because there can be another reference to the same location, or one can just const_cast)
- grogers 4y agoIf the thread you are on doesn't modify the variable (e.g. by const_cast), and that variable isn't atomic or volatile, the compiler should be allowed to treat it as invariant. Whether it does in practice probably depends on a lot of things though.
- varajelle 4y agoYeah, but the compiler need to see through all the functions to find out that there is no const_cast and therefore makes const useless because it could as well see it is not modified. Also it needs to be good at alias analysis.