Why I am a bit confused about this:
std::shared_ptr can be empty and std::shared_ptr can point to null and these two concepts are not equivalent.
an empty shared_ptr can store a non-null value and a shared_ptr that stores null can have a positive ref-count.
What I wonder now is how do I properly test after a std::dynamic_pointer_cast whether the cast was successful or not? the docs https://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast state:
3-4) dynamic_cast<Y*>(r.get()) (If the result of the dynamic_cast is a null pointer value, the returned shared_ptr will be empty.)
but since an empty shared_ptr isn't guaranteed to store a null value, I'm not sure what's the proper well-defined test for whether the dynamic cast succeeded