Only my testimony.
A few years ago, I was still against using const, only because of limitations in design and writing longer function signatures ... and so on ...
But one of my project managers always insisted, all the time, reminding me: "You must use the const function, this avoids accidents and makes no sense."
And one day I came across an impossible mistake. Days after days after days ... A nightmare. The design was too big for me, so I could understand it as a whole. I searched in vain until I decided that I was lost.
Then I spent two days redefining ALL the functions that should be const . I mean this, two days. (The recompilation was long, as it amounted to 5 million lines of project code).
And then: I just found the error ... rather, the compiler found the error for me: in the getter method, which was supposed to give me the preferred size of the gui control, the code actually calculated the size, but it also cached its size and updated its size .. Thus, changing the object.
Now, sometimes I forget to put const. But if I notice him, I will fix it.
Stephane rolling
source share