Skip to content

Commit be03d00

Browse files
mkruskal-googlecopybara-github
authored andcommitted
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
1 parent 1f531be commit be03d00

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

googletest/include/gtest/gtest-printers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
475475
inline void PrintTo(char16_t c, ::std::ostream* os) {
476476
PrintTo(ImplicitCast_<char32_t>(c), os);
477477
}
478-
#ifdef __cpp_char8_t
478+
#ifdef __cpp_lib_char8_t
479479
inline void PrintTo(char8_t c, ::std::ostream* os) {
480480
PrintTo(ImplicitCast_<char32_t>(c), os);
481481
}
@@ -588,7 +588,7 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
588588
inline void PrintTo(unsigned char* s, ::std::ostream* os) {
589589
PrintTo(ImplicitCast_<const void*>(s), os);
590590
}
591-
#ifdef __cpp_char8_t
591+
#ifdef __cpp_lib_char8_t
592592
// Overloads for u8 strings.
593593
GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
594594
inline void PrintTo(char8_t* s, ::std::ostream* os) {
@@ -908,7 +908,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
908908
GTEST_API_ void UniversalPrintArray(const char* begin, size_t len,
909909
::std::ostream* os);
910910

911-
#ifdef __cpp_char8_t
911+
#ifdef __cpp_lib_char8_t
912912
// This overload prints a (const) char8_t array compactly.
913913
GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
914914
::std::ostream* os);

googletest/include/gtest/internal/gtest-port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ inline bool IsUpper(char ch) {
19981998
inline bool IsXDigit(char ch) {
19991999
return isxdigit(static_cast<unsigned char>(ch)) != 0;
20002000
}
2001-
#ifdef __cpp_char8_t
2001+
#ifdef __cpp_lib_char8_t
20022002
inline bool IsXDigit(char8_t ch) {
20032003
return isxdigit(static_cast<unsigned char>(ch)) != 0;
20042004
}

googletest/src/gtest-printers.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static const char* GetCharWidthPrefix(signed char) { return ""; }
216216

217217
static const char* GetCharWidthPrefix(unsigned char) { return ""; }
218218

219-
#ifdef __cpp_char8_t
219+
#ifdef __cpp_lib_char8_t
220220
static const char* GetCharWidthPrefix(char8_t) { return "u8"; }
221221
#endif
222222

@@ -232,7 +232,7 @@ static CharFormat PrintAsStringLiteralTo(char c, ostream* os) {
232232
return PrintAsStringLiteralTo(ToChar32(c), os);
233233
}
234234

235-
#ifdef __cpp_char8_t
235+
#ifdef __cpp_lib_char8_t
236236
static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) {
237237
return PrintAsStringLiteralTo(ToChar32(c), os);
238238
}
@@ -395,7 +395,7 @@ void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
395395
UniversalPrintCharArray(begin, len, os);
396396
}
397397

398-
#ifdef __cpp_char8_t
398+
#ifdef __cpp_lib_char8_t
399399
// Prints a (const) char8_t array of 'len' elements, starting at address
400400
// 'begin'.
401401
void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) {
@@ -438,7 +438,7 @@ void PrintCStringTo(const Char* s, ostream* os) {
438438

439439
void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); }
440440

441-
#ifdef __cpp_char8_t
441+
#ifdef __cpp_lib_char8_t
442442
void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); }
443443
#endif
444444

0 commit comments

Comments
 (0)