diff options
Diffstat (limited to 'googletest/include/gtest/internal/gtest-port.h')
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 60ff4716..ea37fe13 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -202,6 +202,8 @@ // GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or // Matcher<absl::string_view> // specializations. +// GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter<std::variant> or +// UniversalPrinter<absl::variant> specializations. // // Synchronization: // Mutex, MutexLock, ThreadLocal, GetThreadCount() @@ -2251,4 +2253,34 @@ using StringView = ::std::string_view; # endif // __has_include #endif // GTEST_HAS_ABSL +#if GTEST_HAS_ABSL +// Always use absl::variant for UniversalPrinter<> specializations if googletest +// is built with absl support. +# define GTEST_INTERNAL_HAS_VARIANT 1 +#include "absl/types/variant.h" +namespace testing { +namespace internal { +template <typename... T> +using Variant = ::absl::variant<T...>; +} // namespace internal +} // namespace testing +#else +# ifdef __has_include +# if __has_include(<variant>) && __cplusplus >= 201703L +// Otherwise for C++17 and higher use std::variant for UniversalPrinter<> +// specializations. +# define GTEST_INTERNAL_HAS_VARIANT 1 +#include <variant> +namespace testing { +namespace internal { +template <typename... T> +using Variant = ::std::variant<T...>; +} // namespace internal +} // namespace testing +// The case where absl is configured NOT to alias std::variant is not +// supported. +# endif // __has_include(<variant>) && __cplusplus >= 201703L +# endif // __has_include +#endif // GTEST_HAS_ABSL + #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ |