I am trying to perform the following cast and I can't find a way either in the QT documentation or online to make this dynamic cast work which has been confusing:
class Entity : public QSharedData
{
public:
typedef QExplicitlySharedDataPointer<Entity> Pointer;
typedef QExplicitlySharedDataPointer<const Entity> ConstPointer;
...
}
class EntityExtended : public Entity
{
public:
typedef QExplicitlySharedDataPointer<EntityExtended> Pointer;
typedef QExplicitlySharedDataPointer<const EntityExtended> ConstPointer;
...
}
bool SomeClass::createEntity(const Entity::ConstPointer entity)
{
auto extendedEntity = dynamic_cast<const EntityExtended::ConstPointer>(entity);
}
The above produces the error:
error C2680: 'const EntityExtended::ConstPointer': invalid target type for dynamic_cast
note: target type must be a pointer or reference to a defined class
What am I missing?