I am a competitive devil, and I try to do everything as const as possible.
I tried looking at the various disassembly outputs from the const and non const versions of functions, and I still see a noticeable improvement. I assume that compilers these days are capable of doing smart things with non-const functions, which can be technically const.
Are there any other cases where const is useful at the machine level? Any examples?
As far as I know, the only effect of marking a const function is the ability to call a function on an object const. There are no optimization benefits.
const
Herb Sutter has an article discussing const and depth optimization:
, const , - const .
const - , , , , .
const, . , const_cast , ( , , , , const , )
const_cast
, mutable . const , , mutable?
mutable
, , , - , , const , , , .
, , const , , , const , . , , .
const - . - const, , : -, .
, .
const , , , , , .
, . , const , .
, , ++ 0x . , , , , CSE.