diff options
author | Dino Radaković <dinor@google.com> | 2021-03-09 10:59:10 -0800 |
---|---|---|
committer | Dino Radaković <dinor@google.com> | 2021-03-09 10:59:10 -0800 |
commit | bcfcf75ef62af29f15fbb98be25fbfb87f45036e (patch) | |
tree | e7aab07ac6de00c4d07e4358409730c593d72ac9 /googletest/include | |
parent | 79b556eff66383002e7186c30a93a0098625f498 (diff) | |
parent | ac3c2a8d0496893787015014a5abd397b766cce2 (diff) | |
download | googletest-bcfcf75ef62af29f15fbb98be25fbfb87f45036e.tar.gz googletest-bcfcf75ef62af29f15fbb98be25fbfb87f45036e.zip |
Merge pull request #3184 from N-Dekker:PrintTo-type_index-overload
PiperOrigin-RevId: 361175466
Diffstat (limited to 'googletest/include')
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index cd094949..a7e0a3c9 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -113,6 +113,11 @@ #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-port.h" +#if GTEST_HAS_RTTI +#include <typeindex> +#include <typeinfo> +#endif // GTEST_HAS_RTTI + namespace testing { // Definitions in the internal* namespaces are subject to change without notice. @@ -650,6 +655,18 @@ void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) { *os << ')'; } +#if GTEST_HAS_RTTI +inline void PrintTo(const ::std::type_info& value, ::std::ostream* os) { + internal::PrintTo<::std::type_info>(value, os); + *os << " (\"" << value.name() << "\")"; +} + +inline void PrintTo(const ::std::type_index& value, ::std::ostream* os) { + internal::PrintTo<::std::type_index>(value, os); + *os << " (\"" << value.name() << "\")"; +} +#endif // GTEST_HAS_RTTI + // Implements printing a non-reference type T by letting the compiler // pick the right overload of PrintTo() for T. template <typename T> |