summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal/gtest-port.h
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/include/gtest/internal/gtest-port.h')
-rw-r--r--googletest/include/gtest/internal/gtest-port.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 377c77f..75e00cc 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -199,6 +199,8 @@
// suppressed (constant conditional).
// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
// is suppressed.
+// GTEST_INTERNAL_HAS_ANY - for enabling UniversalPrinter<std::any> or
+// UniversalPrinter<absl::any> specializations.
// GTEST_INTERNAL_HAS_OPTIONAL - for enabling UniversalPrinter<std::optional> or
// UniversalPrinter<absl::optional> specializations.
// GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or
@@ -2228,6 +2230,34 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
#endif // !defined(GTEST_INTERNAL_DEPRECATED)
#if GTEST_HAS_ABSL
+// Always use absl::any for UniversalPrinter<> specializations if googletest
+// is built with absl support.
+# define GTEST_INTERNAL_HAS_ANY 1
+#include "absl/types/any.h"
+namespace testing {
+namespace internal {
+using Any = ::absl::any;
+} // namespace internal
+} // namespace testing
+#else
+# ifdef __has_include
+# if __has_include(<any>) && __cplusplus >= 201703L
+// Otherwise for C++17 and higher use std::any for UniversalPrinter<>
+// specializations.
+# define GTEST_INTERNAL_HAS_ANY 1
+#include <any>
+namespace testing {
+namespace internal {
+using Any = ::std::any;
+} // namespace internal
+} // namespace testing
+// The case where absl is configured NOT to alias std::any is not
+// supported.
+# endif // __has_include(<any>) && __cplusplus >= 201703L
+# endif // __has_include
+#endif // GTEST_HAS_ABSL
+
+#if GTEST_HAS_ABSL
// Always use absl::optional for UniversalPrinter<> specializations if googletest
// is built with absl support.
# define GTEST_INTERNAL_HAS_OPTIONAL 1