diff options
author | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-03-07 17:25:51 +0100 |
---|---|---|
committer | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-05-29 13:59:42 +0200 |
commit | eb3953f805d0ed9054dba78b8e842caba0b539c2 (patch) | |
tree | 431b8b25a99617b39a0ba5c8e011e545a6e45865 /googletest/include/gtest/gtest-printers.h | |
parent | 843267f0f1482b470fe14201edfda2c64b68232a (diff) | |
download | googletest-eb3953f805d0ed9054dba78b8e842caba0b539c2.tar.gz googletest-eb3953f805d0ed9054dba78b8e842caba0b539c2.zip |
make UniversalPrinter<std::any> support RTTI
Diffstat (limited to 'googletest/include/gtest/gtest-printers.h')
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 11 |
1 files changed, 9 insertions, 2 deletions
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<Any> { 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<void>(value); // possibly unused + return "the element type"; +#endif // GTEST_HAS_RTTI + } }; #endif // GTEST_INTERNAL_HAS_ANY |