Tested x86_64-linux. -- >8 --
We already enable this for -std=gnu++20 but we can do it for -std=c++20 too. Both libc++ and MSVC also treat this change as a DR for C++20. Now that the previous change to the value of __cpp_lib_format is supported, we can finally update it to 202304 to indicate support for this feature too. libstdc++-v3/ChangeLog: * include/bits/version.def (format): Update value for P2510R3. * include/bits/version.h: Regenerate. * include/std/format (_GLIBCXX_P2518R3): Remove misspelled macro and check __glibcxx_format instead. * testsuite/std/format/functions/format.cc: Check value of the __cpp_lib_format macro for formatting pointers support. * testsuite/std/format/parse_ctx.cc: Likewise. --- libstdc++-v3/include/bits/version.def | 6 +++--- libstdc++-v3/include/bits/version.h | 4 ++-- libstdc++-v3/include/std/format | 16 ++++------------ .../testsuite/std/format/functions/format.cc | 2 +- libstdc++-v3/testsuite/std/format/parse_ctx.cc | 4 ++-- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 74947301760..1acc9cd5cb9 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1162,12 +1162,11 @@ ftms = { ftms = { name = format; - // 202304 P2510R3 Formatting pointers // 202305 P2757R3 Type checking format args // 202306 P2637R3 Member visit // 202311 P2918R2 Runtime format strings II // values = { - // v = 202304; + // v = 202305; // cxxmin = 26; // hosted = yes; // }; @@ -1175,8 +1174,9 @@ ftms = { // 202106 std::format improvements. // 202110 Fixing locale handling in chrono formatters, generator-like types. // 202207 Encodings in localized formatting of chrono, basic-format-string. + // 202304 P2510R3 Formatting pointers values = { - v = 202207; + v = 202304; cxxmin = 20; hosted = yes; }; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 9f8673395da..5cd77770e21 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -1305,9 +1305,9 @@ #if !defined(__cpp_lib_format) # if (__cplusplus >= 202002L) && _GLIBCXX_HOSTED -# define __glibcxx_format 202207L +# define __glibcxx_format 202304L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_format) -# define __cpp_lib_format 202207L +# define __cpp_lib_format 202304L # endif # endif #endif /* !defined(__cpp_lib_format) && defined(__glibcxx_want_format) */ diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index a4921ce391b..487177b5294 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -2342,13 +2342,7 @@ namespace __format // _GLIBCXX_RESOLVE_LIB_DEFECTS // P2510R3 Formatting pointers -#if __glibcxx_format >= 202304L || ! defined __STRICT_ANSI__ -# define _GLIBCXX_P2518R3 1 -#else -# define _GLIBCXX_P2518R3 0 -#endif - -#if _GLIBCXX_P2518R3 +#if __glibcxx_format >= 202304L __first = __spec._M_parse_zero_fill(__first, __last); if (__finished()) return __first; @@ -2360,11 +2354,9 @@ namespace __format { if (*__first == 'p') ++__first; -#if _GLIBCXX_P2518R3 +#if __glibcxx_format >= 202304L else if (*__first == 'P') { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // P2510R3 Formatting pointers __spec._M_type = __format::_Pres_P; ++__first; } @@ -2388,7 +2380,7 @@ namespace __format int __n = __ptr - __buf; __buf[0] = '0'; __buf[1] = 'x'; -#if _GLIBCXX_P2518R3 +#if __glibcxx_format >= 202304L if (_M_spec._M_type == __format::_Pres_P) { __buf[1] = 'X'; @@ -2413,7 +2405,7 @@ namespace __format } #endif -#if _GLIBCXX_P2518R3 +#if __glibcxx_format >= 202304L if (_M_spec._M_zero_fill) { size_t __width = _M_spec._M_get_width(__fc); diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc index 78cc1ab482a..5152bb0b0d0 100644 --- a/libstdc++-v3/testsuite/std/format/functions/format.cc +++ b/libstdc++-v3/testsuite/std/format/functions/format.cc @@ -458,7 +458,7 @@ test_pointer() s = std::format("{:20} {:20p}", p, pc); VERIFY( s == (str_int + ' ' + str_int) ); -#if __cplusplus > 202302L || ! defined __STRICT_ANSI__ +#if __cpp_lib_format >= 202304L // P2510R3 Formatting pointers s = std::format("{:06} {:07P} {:08p}", (void*)0, (const void*)0, nullptr); VERIFY( s == "0x0000 0X00000 0x000000" ); diff --git a/libstdc++-v3/testsuite/std/format/parse_ctx.cc b/libstdc++-v3/testsuite/std/format/parse_ctx.cc index 497427b54e5..3b3201c2a47 100644 --- a/libstdc++-v3/testsuite/std/format/parse_ctx.cc +++ b/libstdc++-v3/testsuite/std/format/parse_ctx.cc @@ -266,8 +266,8 @@ test_pointer() VERIFY( ! is_std_format_spec_for<void*>("G") ); VERIFY( ! is_std_format_spec_for<void*>("+p") ); -#if __cplusplus > 202302L || ! defined __STRICT_ANSI__ - // As an extension, we support P2510R3 Formatting pointers +#if __cpp_lib_format >= 202304L + // P2510R3 Formatting pointers VERIFY( is_std_format_spec_for<void*>("P") ); VERIFY( is_std_format_spec_for<void*>("0p") ); VERIFY( is_std_format_spec_for<void*>("0P") ); -- 2.45.2