C++11 - casting from base class shared_ptr to drived class shared_ptr
1
2
3
4
5
6
7
class BaseClass : public std::enable_shared_from_this<BaseClass>
{
template <typename Derived>
std::shared_ptr<Derived> GetDerived(){
return std::dynamic_pointer_cast<Derived>(shared_from_this());
}
}