dynamic_pointer_cast

template <class Ty, class Other>
    shared_ptr<Ty> dynamic_pointer_cast(const shared_ptr<Other>& sp);

[Added with TR1]

The template function returns an empty shared_ptr object if dynamic_cast<Ty*>(sp.get()) returns a null pointer; otherwise it returns a shared_ptr<Ty> object that owns the resource that is owned by sp. The expression dynamic_cast<Ty*>(sp.get()) must be valid.