[committed] libstdc++: Add missing __cpp_lib_format macro to <version>

Message ID 20230322175003.408005-1-jwakely@redhat.com
State Committed
Commit 02e86035d30e9f7b8645ebb64f4028900fc37126
Headers
Series [committed] libstdc++: Add missing __cpp_lib_format macro to <version> |

Commit Message

Jonathan Wakely March 22, 2023, 5:50 p.m. UTC
  Tested powerpc64le-linux, pushed to trunk.

-- >8--

libstdc++-v3/ChangeLog:

	* include/std/version (__cpp_lib_format): Define.
	* testsuite/std/format/functions/format.cc: Check it.
---
 libstdc++-v3/include/std/version                  |  1 +
 .../testsuite/std/format/functions/format.cc      | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
  

Comments

Daniel Krügler March 22, 2023, 5:58 p.m. UTC | #1
Am Mi., 22. März 2023 um 18:53 Uhr schrieb Jonathan Wakely via
Libstdc++ <libstdc++@gcc.gnu.org>:
>
> Tested powerpc64le-linux, pushed to trunk.
>
> -- >8--
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/version (__cpp_lib_format): Define.
>         * testsuite/std/format/functions/format.cc: Check it.
> ---
>  libstdc++-v3/include/std/version                  |  1 +
>  .../testsuite/std/format/functions/format.cc      | 15 +++++++++++++++
>  2 files changed, 16 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
> index 25ebfc3e512..a19c39c6cdd 100644
> --- a/libstdc++-v3/include/std/version
> +++ b/libstdc++-v3/include/std/version
> @@ -277,6 +277,7 @@
>  #define __cpp_lib_constexpr_utility 201811L
>  #define __cpp_lib_constexpr_vector 201907L
>  #define __cpp_lib_erase_if 202002L
> +#define __cpp_lib_format 202106L

Shouldn't the value be 202207L? (This of-course of your conforming completeness)

Thanks,

- Daniel
  
Jonathan Wakely March 22, 2023, 7:46 p.m. UTC | #2
On Wed, 22 Mar 2023 at 17:59, Daniel Krügler <daniel.kruegler@gmail.com>
wrote:

> Am Mi., 22. März 2023 um 18:53 Uhr schrieb Jonathan Wakely via
> Libstdc++ <libstdc++@gcc.gnu.org>:
> >
> > Tested powerpc64le-linux, pushed to trunk.
> >
> > -- >8--
> >
> > libstdc++-v3/ChangeLog:
> >
> >         * include/std/version (__cpp_lib_format): Define.
> >         * testsuite/std/format/functions/format.cc: Check it.
> > ---
> >  libstdc++-v3/include/std/version                  |  1 +
> >  .../testsuite/std/format/functions/format.cc      | 15 +++++++++++++++
> >  2 files changed, 16 insertions(+)
> >
> > diff --git a/libstdc++-v3/include/std/version
> b/libstdc++-v3/include/std/version
> > index 25ebfc3e512..a19c39c6cdd 100644
> > --- a/libstdc++-v3/include/std/version
> > +++ b/libstdc++-v3/include/std/version
> > @@ -277,6 +277,7 @@
> >  #define __cpp_lib_constexpr_utility 201811L
> >  #define __cpp_lib_constexpr_vector 201907L
> >  #define __cpp_lib_erase_if 202002L
> > +#define __cpp_lib_format 202106L
>
> Shouldn't the value be 202207L? (This of-course of your conforming
> completeness)
>
>
Well spotted!

The historical values listed in SD-6 are included in a comment in <format>:

// 201907 Text Formatting, Integration of chrono, printf corner cases.
// 202106 std::format improvements.
// 202110 Fixing locale handling in chrono formatters, generator-like types.
// 202207 Encodings in localized formatting of chrono, basic-format-string.
#define __cpp_lib_format 202106L

The libstdc++ support only got as far as 202106 so far :-)

(We actually do implement the support for generator-like types from P2418R2
and the std::basic_format_string change from P2508R1, but can't bump the
value to 202207 until the other changes are supported too.)

I might still find time to finish P2372R3 and P2419R2 for GCC 13, but no
promises.
  
Jonathan Wakely March 22, 2023, 7:53 p.m. UTC | #3
On Wed, 22 Mar 2023 at 19:46, Jonathan Wakely <jwakely@redhat.com> wrote:

>
>
> On Wed, 22 Mar 2023 at 17:59, Daniel Krügler <daniel.kruegler@gmail.com>
> wrote:
>
>> Am Mi., 22. März 2023 um 18:53 Uhr schrieb Jonathan Wakely via
>> Libstdc++ <libstdc++@gcc.gnu.org>:
>> >
>> > Tested powerpc64le-linux, pushed to trunk.
>> >
>> > -- >8--
>> >
>> > libstdc++-v3/ChangeLog:
>> >
>> >         * include/std/version (__cpp_lib_format): Define.
>> >         * testsuite/std/format/functions/format.cc: Check it.
>> > ---
>> >  libstdc++-v3/include/std/version                  |  1 +
>> >  .../testsuite/std/format/functions/format.cc      | 15 +++++++++++++++
>> >  2 files changed, 16 insertions(+)
>> >
>> > diff --git a/libstdc++-v3/include/std/version
>> b/libstdc++-v3/include/std/version
>> > index 25ebfc3e512..a19c39c6cdd 100644
>> > --- a/libstdc++-v3/include/std/version
>> > +++ b/libstdc++-v3/include/std/version
>> > @@ -277,6 +277,7 @@
>> >  #define __cpp_lib_constexpr_utility 201811L
>> >  #define __cpp_lib_constexpr_vector 201907L
>> >  #define __cpp_lib_erase_if 202002L
>> > +#define __cpp_lib_format 202106L
>>
>> Shouldn't the value be 202207L? (This of-course of your conforming
>> completeness)
>>
>>
> Well spotted!
>
> The historical values listed in SD-6 are included in a comment in <format>:
>
> // 201907 Text Formatting, Integration of chrono, printf corner cases.
> // 202106 std::format improvements.
> // 202110 Fixing locale handling in chrono formatters, generator-like
> types.
> // 202207 Encodings in localized formatting of chrono, basic-format-string.
> #define __cpp_lib_format 202106L
>
> The libstdc++ support only got as far as 202106 so far :-)
>
> (We actually do implement the support for generator-like types from
> P2418R2 and the std::basic_format_string change from P2508R1, but can't
> bump the value to 202207 until the other changes are supported too.)
>
> I might still find time to finish P2372R3 and P2419R2 for GCC 13, but no
> promises.
>

Hmm, actually maybe I already did all of P2372R3 as part of the <chrono>
formatting, so it should be 202110. And for P2419R2 we could say that the
implementation-defined set of locales is empty ... but that's pretty poor
QoI.

There are also some more changes in C++23 (P2572 and P2675) which aren't
done yet.
  

Patch

diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 25ebfc3e512..a19c39c6cdd 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -277,6 +277,7 @@ 
 #define __cpp_lib_constexpr_utility 201811L
 #define __cpp_lib_constexpr_vector 201907L
 #define __cpp_lib_erase_if 202002L
+#define __cpp_lib_format 202106L
 #define __cpp_lib_generic_unordered_lookup 201811L
 #define __cpp_lib_interpolate 201902L
 #ifdef _GLIBCXX_HAS_GTHREADS
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc
index 7a155208a48..2a1b1560394 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -2,6 +2,21 @@ 
 // { dg-do run { target c++20 } }
 
 #include <format>
+
+#ifndef __cpp_lib_format
+# error "Feature test macro for std::format is missing in <format>"
+#elif __cpp_lib_format < 202106L
+# error "Feature test macro for std::format has wrong value in <format>"
+#endif
+
+#undef __cpp_lib_format
+#include <version>
+#ifndef __cpp_lib_format
+# error "Feature test macro for std::format is missing in <version>"
+#elif __cpp_lib_format < 202106L
+# error "Feature test macro for std::format has wrong value in <version>"
+#endif
+
 #include <string>
 #include <limits>
 #include <cstdint>