diff options
author | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-03-07 17:03:50 +0100 |
---|---|---|
committer | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-05-29 13:59:42 +0200 |
commit | 843267f0f1482b470fe14201edfda2c64b68232a (patch) | |
tree | a94980e564c8bc25800839864009609df5a6be52 /googletest/include/gtest/gtest-printers.h | |
parent | 95b0ea2cf5046465f448f01efa7c4b764a62a4bb (diff) | |
download | googletest-843267f0f1482b470fe14201edfda2c64b68232a.tar.gz googletest-843267f0f1482b470fe14201edfda2c64b68232a.zip |
specialize UniversalPrinter<> for std::any (without support for RTTI)
Diffstat (limited to 'googletest/include/gtest/gtest-printers.h')
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 4260e4f7..67c87f47 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -679,6 +679,26 @@ class UniversalPrinter { GTEST_DISABLE_MSC_WARNINGS_POP_() }; +#if GTEST_INTERNAL_HAS_ANY + +// Printer for std::any / absl::any + +template <> +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(); + else + *os << "'any' type with no value"; + } + + private: + static std::string GetTypeName() { return "the element type"; } +}; + +#endif // GTEST_INTERNAL_HAS_ANY + #if GTEST_INTERNAL_HAS_OPTIONAL // Printer for std::optional / absl::optional |