taxonony::cast throws exceptions now on invalid casts

This commit is contained in:
Thomas Krijnen
2024-06-18 13:52:42 +02:00
parent f5979be4d5
commit 691fe549d7
+5 -1
View File
@@ -1239,7 +1239,11 @@ typedef item const* ptr;
if (pwupg) {
return pwupg;
}
return std::static_pointer_cast<T>(u);
if (auto r = std::dynamic_pointer_cast<T>(u)) {
return r;
} else {
throw std::runtime_error("Unexpected topology");
}
}
template <typename T, typename U>
std::shared_ptr<T> dcast(const std::shared_ptr<U>& u) {