I have a class hierarchy and in it B
is derived from A
like this:
class A : public std::enable_shared_from_this<A>
{
};
class B : public A
{
void f()
{
// the code below compiles
std::shared_ptr<B> copyOfThis = std::static_pointer_cast<B>(shared_from_this());
// the code below does not
std::shared_ptr<B> copyOfThis = static_cast<std::shared_ptr<B>>(std::make_shared<A>(shared_from_this()));
}
};
Aucun commentaire:
Enregistrer un commentaire