diff options
author | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-03-07 14:48:20 (GMT) |
---|---|---|
committer | Krystian Kuzniarek <krystian.kuzniarek@gmail.com> | 2020-05-29 11:59:42 (GMT) |
commit | 95b0ea2cf5046465f448f01efa7c4b764a62a4bb (patch) | |
tree | c0275686d3542451e8cdf30eddea36b2f0256c01 /googletest/include/gtest/internal/gtest-port.h | |
parent | 33b44c4b35b5b24624c1203001e36df2dbab346b (diff) | |
download | googletest-95b0ea2cf5046465f448f01efa7c4b764a62a4bb.zip googletest-95b0ea2cf5046465f448f01efa7c4b764a62a4bb.tar.gz googletest-95b0ea2cf5046465f448f01efa7c4b764a62a4bb.tar.bz2 |
specialize UniversalPrinter<> for std::optional
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 ea37fe1..377c77f 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_OPTIONAL - for enabling UniversalPrinter<std::optional> or +// UniversalPrinter<absl::optional> specializations. // GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or // Matcher<absl::string_view> // specializations. @@ -2226,6 +2228,36 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); #endif // !defined(GTEST_INTERNAL_DEPRECATED) #if GTEST_HAS_ABSL +// Always use absl::optional for UniversalPrinter<> specializations if googletest +// is built with absl support. +# define GTEST_INTERNAL_HAS_OPTIONAL 1 +#include "absl/types/optional.h" +namespace testing { +namespace internal { +template <typename T> +using Optional = ::absl::optional<T>; +} // namespace internal +} // namespace testing +#else +# ifdef __has_include +# if __has_include(<optional>) && __cplusplus >= 201703L +// Otherwise for C++17 and higher use std::optional for UniversalPrinter<> +// specializations. +# define GTEST_INTERNAL_HAS_OPTIONAL 1 +#include <optional> +namespace testing { +namespace internal { +template <typename T> +using Optional = ::std::optional<T>; +} // namespace internal +} // namespace testing +// The case where absl is configured NOT to alias std::optional is not +// supported. +# endif // __has_include(<optional>) && __cplusplus >= 201703L +# endif // __has_include +#endif // GTEST_HAS_ABSL + +#if GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. # define GTEST_INTERNAL_HAS_STRING_VIEW 1 |