Let's say I have Base and Derived classes:
class Base {
public:
virtual auto DoSomething(const Base&) const -> decltype(*this) = 0;
};
class Derived : public Base {
public:
const Derived& DoSomething(const Base&) const override; // OK, but not what I want
// Derived DoSomething(const Base&) const override; // ERROR, but I want this
};
The uncommented code compiles fine, and works fine if you fill it out. But I don't want to return a const reference from DoSomething(). Is there any way to strip the modifiers from the trailing return type in the base class declaration? I've tried a few methods from <type_traits> (remove_cvref_t, etc), but they seem to evaluate the type to Base, which creates a conflicting return type.
If what I'm trying to do is not possible, why is it not possible?