News for hackers. Stuff that matters.
Re:Add a const here, delete a const there by Arnt on Monday January 09, 2017 @08:11AM (#13356067)
You can overload on const in C++, so int a(foo b) and int a(const foo b) can coexist. We used this in Qt 2.0, there were a few cases where we could get significantly more oomph if we knew the argument was const.

Ff a function takes a struct (or class) as argument can calls otherfunction(foo.bar), then the constness of foo's bar field matters. The same might apply to fields of this.

Re:Add a const here, delete a const there by pontobart on Monday January 09, 2017 @04:58PM (#13360212)
You cannot overload on the const. If you try to define both int a(int b) and int a(const int b) the compiler will complain about a redefinition.

You can declare the function using int a(int b) in the header and then define it via int a(const int b).

Re:Add a const here, delete a const there by wfunction on Monday January 09, 2017 @08:19AM (#13356107)
Nobody said it doesn't "matter" whether you put const. I was saying it's not worthwhile.