Fix C++20 compatibility bug.

This was shown to work for C++14, C++17, and C++20 after patched into googletest for the protobuf repo's CI.

Closes #3659

PiperOrigin-RevId: 544795507
Change-Id: I3e0a94f675e78a6ee9aeccae86c23d940efed8eb
This commit is contained in:
Mike Kruskal 2023-06-30 18:49:33 -07:00 committed by Copybara-Service
parent 1f531be3a1
commit be03d00f5f
3 changed files with 8 additions and 8 deletions

View File

@ -475,7 +475,7 @@ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
inline void PrintTo(char16_t c, ::std::ostream* os) { inline void PrintTo(char16_t c, ::std::ostream* os) {
PrintTo(ImplicitCast_<char32_t>(c), os); PrintTo(ImplicitCast_<char32_t>(c), os);
} }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
inline void PrintTo(char8_t c, ::std::ostream* os) { inline void PrintTo(char8_t c, ::std::ostream* os) {
PrintTo(ImplicitCast_<char32_t>(c), os); PrintTo(ImplicitCast_<char32_t>(c), os);
} }
@ -588,7 +588,7 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
inline void PrintTo(unsigned char* s, ::std::ostream* os) { inline void PrintTo(unsigned char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os); PrintTo(ImplicitCast_<const void*>(s), os);
} }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
// Overloads for u8 strings. // Overloads for u8 strings.
GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os); GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
inline void PrintTo(char8_t* s, ::std::ostream* os) { inline void PrintTo(char8_t* s, ::std::ostream* os) {
@ -908,7 +908,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
GTEST_API_ void UniversalPrintArray(const char* begin, size_t len, GTEST_API_ void UniversalPrintArray(const char* begin, size_t len,
::std::ostream* os); ::std::ostream* os);
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
// This overload prints a (const) char8_t array compactly. // This overload prints a (const) char8_t array compactly.
GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len, GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
::std::ostream* os); ::std::ostream* os);

View File

@ -1998,7 +1998,7 @@ inline bool IsUpper(char ch) {
inline bool IsXDigit(char ch) { inline bool IsXDigit(char ch) {
return isxdigit(static_cast<unsigned char>(ch)) != 0; return isxdigit(static_cast<unsigned char>(ch)) != 0;
} }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
inline bool IsXDigit(char8_t ch) { inline bool IsXDigit(char8_t ch) {
return isxdigit(static_cast<unsigned char>(ch)) != 0; return isxdigit(static_cast<unsigned char>(ch)) != 0;
} }

View File

@ -216,7 +216,7 @@ static const char* GetCharWidthPrefix(signed char) { return ""; }
static const char* GetCharWidthPrefix(unsigned char) { return ""; } static const char* GetCharWidthPrefix(unsigned char) { return ""; }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
static const char* GetCharWidthPrefix(char8_t) { return "u8"; } static const char* GetCharWidthPrefix(char8_t) { return "u8"; }
#endif #endif
@ -232,7 +232,7 @@ static CharFormat PrintAsStringLiteralTo(char c, ostream* os) {
return PrintAsStringLiteralTo(ToChar32(c), os); return PrintAsStringLiteralTo(ToChar32(c), os);
} }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) { static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) {
return PrintAsStringLiteralTo(ToChar32(c), os); return PrintAsStringLiteralTo(ToChar32(c), os);
} }
@ -395,7 +395,7 @@ void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
UniversalPrintCharArray(begin, len, os); UniversalPrintCharArray(begin, len, os);
} }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
// Prints a (const) char8_t array of 'len' elements, starting at address // Prints a (const) char8_t array of 'len' elements, starting at address
// 'begin'. // 'begin'.
void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) { void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) {
@ -438,7 +438,7 @@ void PrintCStringTo(const Char* s, ostream* os) {
void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); } void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); }
#ifdef __cpp_char8_t #ifdef __cpp_lib_char8_t
void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); } void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); }
#endif #endif