class Foo { public: const int& get() const { //non-trivial work return foo; } int& get() { return const_cast<int&>(const_cast<const Foo*>(this)->get()); } };