(dynamic_cast is safe as long as it's used only on pointer values; do not use it on reference types, since that can throw)