lundi 13 juillet 2020

Check whether the current underlying type of a std::shared_str<> is T

I have a shared pointer storing a base class, like this:

std::shared_ptr<Base> baseClassPointer;

How do I check whether it is currently holding an instance of an SuperClassA? Where:

public class SuperClassA : public Base {} // There can be many other superclasses

I've tried something like below, but obviously did not work:

std::is_same<SuperClassA, decltype(baseClassPointer->get())>::value;

Aucun commentaire:

Enregistrer un commentaire