Returns: shared_ptr<T>(R, static_cast<typename shared_ptr<T>::element_type*>(r.get()))
where R is r for the first overload, and
std::move(r) for the second.
The seemingly equivalent expression
shared_ptr<T>(static_cast<T*>(r.get()))
will eventually result in undefined behavior, attempting to delete the
same object twice.
When dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())
returns a non-null value p,
shared_ptr<T>(R, p),
where R is r for the first overload, and
std::move(r) for the second.
The seemingly equivalent expression
shared_ptr<T>(dynamic_cast<T*>(r.get())) will eventually result in
undefined behavior, attempting to delete the same object twice.
Returns: shared_ptr<T>(R, const_cast<typename shared_ptr<T>::element_type*>(r.get()))
where R is r for the first overload, and
std::move(r) for the second.
The seemingly equivalent expression
shared_ptr<T>(const_cast<T*>(r.get())) will eventually result in
undefined behavior, attempting to delete the same object twice.
Returns: shared_ptr<T>(R, reinterpret_cast<typename shared_ptr<T>::element_type*>(r.get()))
where R is r for the first overload, and
std::move(r) for the second.
The seemingly equivalent expression
shared_ptr<T>(reinterpret_cast<T*>(r.get())) will eventually result in
undefined behavior, attempting to delete the same object twice.