From eb3953f805d0ed9054dba78b8e842caba0b539c2 Mon Sep 17 00:00:00 2001 From: Krystian Kuzniarek Date: Sat, 7 Mar 2020 17:25:51 +0100 Subject: make UniversalPrinter support RTTI --- googletest/include/gtest/gtest-printers.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'googletest/include/gtest/gtest-printers.h') diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 67c87f47..718e6f13 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -688,13 +688,20 @@ class UniversalPrinter { public: static void Print(const Any& value, ::std::ostream* os) { if (value.has_value()) - *os << "'any' type with value of type " << GetTypeName(); + *os << "'any' type with value of type " << GetTypeName(value); else *os << "'any' type with no value"; } private: - static std::string GetTypeName() { return "the element type"; } + static std::string GetTypeName(const Any& value) { +#if GTEST_HAS_RTTI + return internal::GetTypeName(value.type()); +#else + static_cast(value); // possibly unused + return "the element type"; +#endif // GTEST_HAS_RTTI + } }; #endif // GTEST_INTERNAL_HAS_ANY -- cgit v1.2.1