diff --git a/be/src/core/assert_cast.h b/be/src/core/assert_cast.h index 57e1125f88c4c3..acadf8705a71d5 100644 --- a/be/src/core/assert_cast.h +++ b/be/src/core/assert_cast.h @@ -42,6 +42,9 @@ struct AssertCastNormalizedType { template using AssertCastNormalizedType_t = typename AssertCastNormalizedType::type; +template +using AssertCastClassType_t = std::remove_pointer_t>; + /** Perform static_cast in release build when TypeCheckOnRelease is set to DISABLE. * Checks type by comparing typeid and throw an exception in all the other situations. * The exact match of the type is checked. That is, cast to the ancestor will be unsuccessful. @@ -50,6 +53,11 @@ template , AssertCastNormalizedType_t>, "assert_cast is redundant for the same type after removing cv/ref qualifiers"); + static_assert(std::is_class_v> && + std::is_class_v>, + "assert_cast requires casting between class pointer/reference types"); + static_assert(std::is_base_of_v, AssertCastClassType_t>, + "assert_cast only supports downcast from a base type to a derived type"); // https://godbolt.org/z/nrsx7nYhs // perform_cast will not be compiled to asm in release build with TypeCheckOnRelease::DISABLE