specialize UniversalPrinter<> for std::any (without support for RTTI)

This commit is contained in:
Krystian Kuzniarek
2020-03-07 17:03:50 +01:00
parent 95b0ea2cf5
commit 843267f0f1
4 changed files with 72 additions and 0 deletions

View File

@@ -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