News for hackers. Stuff that matters.
Re:C++ Is the Next C++ by account42 on Thursday November 03, 2022 @05:59AM (#33448976)
> It allows more sensible code and compiler optimizations.

Unfortunately no, const only tells the compiler optimizer something when applied to variables but not for reference or pointer types (or member functions, where it just means apply const to the this pointer). It would be nice if there were a stronger co_const that would tell the compiler could assume is never cast away (or at least that the variable is not modified through that pointer/reference even if the const is cast away) but C++ const is not that.

Re:C++ Is the Next C++ by kllrnohj on Thursday November 03, 2022 @12:18PM (#33453340)
The const in this example is on the member function so nothing external can cast it away, but the value of it there is really more about contract/behavioral enforcement than optimizations yes.