Creates a new instance of std::shared_ptr whose managed object type is obtained from the
r's managed object type using a cast expression. Both smart pointers will share the ownership of the managed object.
The resulting std::shared_ptr's managed object will be obtained by calling (in respective order):
dynamic_cast<T*>(r.get()) (If the result of the
dynamic_cast is a null pointer value, the returned
shared_ptr will be empty).
In any case, if the parameter
r is an empty std::shared_ptr the result will be a new empty std::shared_ptr.
|| The pointer to convert
The expressions std::shared_ptr<T>(static_cast<T*>(r.get())), std::shared_ptr<T>(dynamic_cast<T*>(r.get())) and std::shared_ptr<T>(const_cast<T*>(r.get())) might seem to have the same effect, but they all will eventually result in undefined behavior, attempting to delete the same object twice!
 Possible implementation
 See also