What's wrong with this code?
class Event;
class EventPtr : public std::shared_ptr<Event>
{
public:
template<typename T>
std::shared_ptr<T> castTo() {
return std::dynamic_pointer_cast<T>(this);
}
};
I get the following compile error: no matching function for call to 'dynamic_pointer_cast'
Below is the usage:
void SomeClass::onEvent(EventPtr event)
{
auto e = event.castTo<SomeEvent>();
// using casted event
}
Aucun commentaire:
Enregistrer un commentaire