Getting a shared pointer to a derived class when base class inherits from enable_shared_from_this
- by Nikhil
I have a class B which inherits from A which in turn derives from enabled_shared_from_this. Now, I want to get a shared pointer to B from an instance of B. shared_from_this will return shared_ptr<A>, not shared_ptr<B>. Should I use boost::static_pointer_cast here? Or is there a better way?