1 hour ago, JoeJ said:
Aehm... what means the first const for the return type?
I do const correctness just for a year and googling never gave me the answer
That basically prevents calling assignment operators (and other non-const methods) on your returned value.
For instance if you have some class Number and return a const Number for an overloaded operator*, the following will not be possible:
(a * b) = c;
This can avoid typos such as: if ((a * b) = c) instead of if ((a * b) == c).
So as a rule of thumb, always use const for returning by value of non-primitive, non-enum types. The latter are immutable by definition, so adding a const results in no added value. (See: Effective C++ of Scott Meyers)
As another rule of thumb, which is mostly ignored in code that I see, put the immutable value to the left when comparing against some possible mutable value:
if (5 == value)
or
if (5 == SomeExternalLibraryFunctionWhichDoesNotReturnAConstValue())