Don't you hate it when you have
class Foobar {
public:
Something& getSomething(int index) {
// big, non-trivial chunk of code...
return something;
}
const Something& getSomething(int index) const {
// big, non-trivial chunk of code...
return something;
}
}
We can't implement either of this methods with the other one, because you can't call the non-const version from the const version (compiler error).
A cast will be required to call the const version from the non-const one.
Is there a real elegant solution to this, if not, what is the closest to one?