Invalid covariant return type
От: vng Беларусь https://organicmaps.app/
Дата: 09.10.20 10:13
Оценка:
class BaseI
{
public:
    virtual BaseI * foo() = 0;
};

template <class Derived> class BaseT : public BaseI
{
public:
    virtual Derived * foo() override
    {
        return new Derived();
    }
};

class Derive1 : public BaseT<Derive1> {};
class Derive2 : public BaseT<Derive2> {};


Получаю ошибку компиляции "Invalid covariant return type" хотя фактически они covariant. Есть ли объяснение почему так?
Re: Invalid covariant return type
От: reversecode google
Дата: 09.10.20 10:34
Оценка: 8 (2) +1
https://stackoverflow.com/questions/30252032/invalid-covariant-type-with-crtp-clonable-class
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.