zhiqiang-hhhh commented on code in PR #32614:
URL: https://github.com/apache/doris/pull/32614#discussion_r1536591881


##########
be/src/vec/common/typeid_cast.h:
##########
@@ -43,34 +43,20 @@
   */
 template <typename To, typename From>
     requires std::is_reference_v<To>
-To typeid_cast(From& from) {
-    try {
-        if (typeid(from) == typeid(To)) {
-            return static_cast<To>(from);
-        }
-    } catch (const std::exception& e) {
-        throw doris::Exception(doris::ErrorCode::BAD_CAST, e.what());
-    }
+To typeid_cast(From& from) noexcept(false) {
+    if ((typeid(From) == typeid(To)) || (typeid(from) == typeid(To))) return 
static_cast<To>(from);
 
     throw doris::Exception(doris::ErrorCode::BAD_CAST,
                            "Bad cast from type " + 
demangle(typeid(from).name()) + " to " +
                                    demangle(typeid(To).name()));
 }
 
 template <typename To, typename From>
-To typeid_cast(From* from) {
-#ifndef NDEBUG
-    try {
-        if (typeid(*from) == typeid(std::remove_pointer_t<To>)) {
-            return static_cast<To>(from);
-        }
-    } catch (const std::exception& e) {
-        throw doris::Exception(doris::ErrorCode::BAD_CAST, e.what());
-    }
-#else
-    if (typeid(*from) == typeid(std::remove_pointer_t<To>)) {
+    requires std::is_pointer_v<To>
+To typeid_cast(From* from) noexcept {

Review Comment:
   I dont know whether `typeid_cast(nullptr)` is designed as a common use 
scenario



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to