|
@@ -35,9 +35,12 @@
|
|
|
|
|
|
#include <google/protobuf/stubs/common.h>
|
|
#include <google/protobuf/stubs/common.h>
|
|
|
|
|
|
|
|
+#include <google/protobuf/port_def.inc>
|
|
|
|
+
|
|
namespace google {
|
|
namespace google {
|
|
namespace protobuf {
|
|
namespace protobuf {
|
|
namespace internal {
|
|
namespace internal {
|
|
|
|
+
|
|
// Use implicit_cast as a safe version of static_cast or const_cast
|
|
// Use implicit_cast as a safe version of static_cast or const_cast
|
|
// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
|
|
// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
|
|
// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
|
|
// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
|
|
@@ -88,7 +91,7 @@ inline To down_cast(From* f) { // so we only accept pointers
|
|
implicit_cast<From*, To>(0);
|
|
implicit_cast<From*, To>(0);
|
|
}
|
|
}
|
|
|
|
|
|
-#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
|
|
|
|
|
|
+#if !defined(NDEBUG) && PROTOBUF_RTTI
|
|
assert(f == nullptr || dynamic_cast<To>(f) != nullptr); // RTTI: debug mode only!
|
|
assert(f == nullptr || dynamic_cast<To>(f) != nullptr); // RTTI: debug mode only!
|
|
#endif
|
|
#endif
|
|
return static_cast<To>(f);
|
|
return static_cast<To>(f);
|
|
@@ -105,7 +108,7 @@ inline To down_cast(From& f) {
|
|
implicit_cast<From*, ToAsPointer>(0);
|
|
implicit_cast<From*, ToAsPointer>(0);
|
|
}
|
|
}
|
|
|
|
|
|
-#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
|
|
|
|
|
|
+#if !defined(NDEBUG) && PROTOBUF_RTTI
|
|
// RTTI: debug mode only!
|
|
// RTTI: debug mode only!
|
|
assert(dynamic_cast<ToAsPointer>(&f) != nullptr);
|
|
assert(dynamic_cast<ToAsPointer>(&f) != nullptr);
|
|
#endif
|
|
#endif
|
|
@@ -131,4 +134,7 @@ using internal::bit_cast;
|
|
|
|
|
|
} // namespace protobuf
|
|
} // namespace protobuf
|
|
} // namespace google
|
|
} // namespace google
|
|
|
|
+
|
|
|
|
+#include <google/protobuf/port_undef.inc>
|
|
|
|
+
|
|
#endif // GOOGLE_PROTOBUF_CASTS_H__
|
|
#endif // GOOGLE_PROTOBUF_CASTS_H__
|