public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Adding missing feature-test macros for C++23 ranges algos
@ 2023-04-17  3:45 Patrick Palka
  2023-04-18  8:56 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2023-04-17  3:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

This patch also renames __cpp_lib_fold to __cpp_lib_ranges_fold
as per the current draft standard.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__cpp_lib_ranges_contains):
	Define for C++23.
	(__cpp_lib_ranges_iota): Likewise.
	(__cpp_lib_ranges_find_last): Likewise.
	(__cpp_lib_fold): Rename to ...
	(__cpp_lib_ranges_fold): ... this.
	* include/std/version: As above.
	* testsuite/25_algorithms/fold_left/1.cc: Adjust after
	renaming __cpp_lib_fold.
	* testsuite/std/ranges/version_c++23.cc: Verify values
	of the above feature-test macros.
---
 libstdc++-v3/include/bits/ranges_algo.h          |  9 ++++++++-
 libstdc++-v3/include/std/version                 |  5 ++++-
 .../testsuite/25_algorithms/fold_left/1.cc       |  4 ++--
 .../testsuite/std/ranges/version_c++23.cc        | 16 ++++++++++++++++
 4 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h
index f041ff16b0e..410d3ae1dd8 100644
--- a/libstdc++-v3/include/bits/ranges_algo.h
+++ b/libstdc++-v3/include/bits/ranges_algo.h
@@ -3468,6 +3468,9 @@ namespace ranges
   inline constexpr __prev_permutation_fn prev_permutation{};
 
 #if __cplusplus > 202002L
+
+#define __cpp_lib_ranges_contains 202207L
+
   struct __contains_fn
   {
     template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
@@ -3521,6 +3524,8 @@ namespace ranges
 
   inline constexpr __contains_subrange_fn contains_subrange{};
 
+#define __cpp_lib_ranges_iota 202202L
+
   template<typename _Out, typename _Tp>
     struct out_value_result
     {
@@ -3569,6 +3574,8 @@ namespace ranges
 
   inline constexpr __iota_fn iota{};
 
+#define __cpp_lib_ranges_find_last 202207L
+
   struct __find_last_fn
   {
     template<forward_iterator _Iter, sentinel_for<_Iter> _Sent, typename _Tp, typename _Proj = identity>
@@ -3695,7 +3702,7 @@ namespace ranges
 
   inline constexpr __find_last_if_not_fn find_last_if_not{};
 
-#define __cpp_lib_fold 202207L
+#define __cpp_lib_ranges_fold 202207L
 
   template<typename _Iter, typename _Tp>
     struct in_value_result
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 9f31f25f1e9..027e5711ec5 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -341,7 +341,10 @@
 #define __cpp_lib_ranges_as_rvalue 202207L
 #define __cpp_lib_ranges_as_const 202207L
 #define __cpp_lib_ranges_enumerate 202302L
-#define __cpp_lib_fold 202207L
+#define __cpp_lib_ranges_contains 202207L
+#define __cpp_lib_ranges_iota 202202L
+#define __cpp_lib_ranges_find_last 202207L
+#define __cpp_lib_ranges_fold 202207L
 #if __cpp_constexpr_dynamic_alloc
 # if _GLIBCXX_HOSTED
 #  define __cpp_lib_constexpr_bitset 202202L
diff --git a/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc b/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc
index 5cc91b67d27..4041d13315f 100644
--- a/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc
@@ -5,8 +5,8 @@
 #include <ranges>
 #include <testsuite_iterators.h>
 
-#if __cpp_lib_fold != 202207L
-# error "Feature-test macro __cpp_lib_fold has wrong value in <algorithm>"
+#if __cpp_lib_ranges_fold != 202207L
+# error "Feature-test macro __cpp_lib_ranges_fold has wrong value in <algorithm>"
 #endif
 
 namespace ranges = std::ranges;
diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
index e2c14edc8ef..04609bb602c 100644
--- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
+++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
@@ -52,3 +52,19 @@
 #if __cpp_lib_ranges_enumerate != 202302L
 # error "Feature-test macro __cpp_lib_ranges_enumerate has wrong value in <version>"
 #endif
+
+#if __cpp_lib_ranges_contains != 202207L
+# error "Feature-test macro __cpp_lib_ranges_contains has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_iota != 202202L
+# error "Feature-test macro __cpp_lib_ranges_iota has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_find_last != 202207L
+# error "Feature-test macro __cpp_lib_ranges_find_last has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_fold != 202207L
+# error "Feature-test macro __cpp_lib_ranges_fold has wrong value in <version>"
+#endif
-- 
2.40.0.335.g9857273be0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libstdc++: Adding missing feature-test macros for C++23 ranges algos
  2023-04-17  3:45 [PATCH] libstdc++: Adding missing feature-test macros for C++23 ranges algos Patrick Palka
@ 2023-04-18  8:56 ` Jonathan Wakely
  2023-04-18  8:59   ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2023-04-18  8:56 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++, Jakub Jelinek

On Mon, 17 Apr 2023 at 04:46, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> This patch also renames __cpp_lib_fold to __cpp_lib_ranges_fold
> as per the current draft standard.

OK, but this needs RM approval to push to gcc-13


>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/ranges_algo.h (__cpp_lib_ranges_contains):
>         Define for C++23.
>         (__cpp_lib_ranges_iota): Likewise.
>         (__cpp_lib_ranges_find_last): Likewise.
>         (__cpp_lib_fold): Rename to ...
>         (__cpp_lib_ranges_fold): ... this.
>         * include/std/version: As above.
>         * testsuite/25_algorithms/fold_left/1.cc: Adjust after
>         renaming __cpp_lib_fold.
>         * testsuite/std/ranges/version_c++23.cc: Verify values
>         of the above feature-test macros.
> ---
>  libstdc++-v3/include/bits/ranges_algo.h          |  9 ++++++++-
>  libstdc++-v3/include/std/version                 |  5 ++++-
>  .../testsuite/25_algorithms/fold_left/1.cc       |  4 ++--
>  .../testsuite/std/ranges/version_c++23.cc        | 16 ++++++++++++++++
>  4 files changed, 30 insertions(+), 4 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h
> index f041ff16b0e..410d3ae1dd8 100644
> --- a/libstdc++-v3/include/bits/ranges_algo.h
> +++ b/libstdc++-v3/include/bits/ranges_algo.h
> @@ -3468,6 +3468,9 @@ namespace ranges
>    inline constexpr __prev_permutation_fn prev_permutation{};
>
>  #if __cplusplus > 202002L
> +
> +#define __cpp_lib_ranges_contains 202207L
> +
>    struct __contains_fn
>    {
>      template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
> @@ -3521,6 +3524,8 @@ namespace ranges
>
>    inline constexpr __contains_subrange_fn contains_subrange{};
>
> +#define __cpp_lib_ranges_iota 202202L
> +
>    template<typename _Out, typename _Tp>
>      struct out_value_result
>      {
> @@ -3569,6 +3574,8 @@ namespace ranges
>
>    inline constexpr __iota_fn iota{};
>
> +#define __cpp_lib_ranges_find_last 202207L
> +
>    struct __find_last_fn
>    {
>      template<forward_iterator _Iter, sentinel_for<_Iter> _Sent, typename _Tp, typename _Proj = identity>
> @@ -3695,7 +3702,7 @@ namespace ranges
>
>    inline constexpr __find_last_if_not_fn find_last_if_not{};
>
> -#define __cpp_lib_fold 202207L
> +#define __cpp_lib_ranges_fold 202207L
>
>    template<typename _Iter, typename _Tp>
>      struct in_value_result
> diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
> index 9f31f25f1e9..027e5711ec5 100644
> --- a/libstdc++-v3/include/std/version
> +++ b/libstdc++-v3/include/std/version
> @@ -341,7 +341,10 @@
>  #define __cpp_lib_ranges_as_rvalue 202207L
>  #define __cpp_lib_ranges_as_const 202207L
>  #define __cpp_lib_ranges_enumerate 202302L
> -#define __cpp_lib_fold 202207L
> +#define __cpp_lib_ranges_contains 202207L
> +#define __cpp_lib_ranges_iota 202202L
> +#define __cpp_lib_ranges_find_last 202207L
> +#define __cpp_lib_ranges_fold 202207L
>  #if __cpp_constexpr_dynamic_alloc
>  # if _GLIBCXX_HOSTED
>  #  define __cpp_lib_constexpr_bitset 202202L
> diff --git a/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc b/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc
> index 5cc91b67d27..4041d13315f 100644
> --- a/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc
> +++ b/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc
> @@ -5,8 +5,8 @@
>  #include <ranges>
>  #include <testsuite_iterators.h>
>
> -#if __cpp_lib_fold != 202207L
> -# error "Feature-test macro __cpp_lib_fold has wrong value in <algorithm>"
> +#if __cpp_lib_ranges_fold != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_fold has wrong value in <algorithm>"
>  #endif
>
>  namespace ranges = std::ranges;
> diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> index e2c14edc8ef..04609bb602c 100644
> --- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> @@ -52,3 +52,19 @@
>  #if __cpp_lib_ranges_enumerate != 202302L
>  # error "Feature-test macro __cpp_lib_ranges_enumerate has wrong value in <version>"
>  #endif
> +
> +#if __cpp_lib_ranges_contains != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_contains has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_iota != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_iota has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_find_last != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_find_last has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_fold != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_fold has wrong value in <version>"
> +#endif
> --
> 2.40.0.335.g9857273be0
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libstdc++: Adding missing feature-test macros for C++23 ranges algos
  2023-04-18  8:56 ` Jonathan Wakely
@ 2023-04-18  8:59   ` Jakub Jelinek
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2023-04-18  8:59 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Patrick Palka, gcc-patches, libstdc++

On Tue, Apr 18, 2023 at 09:56:33AM +0100, Jonathan Wakely wrote:
> On Mon, 17 Apr 2023 at 04:46, Patrick Palka via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > This patch also renames __cpp_lib_fold to __cpp_lib_ranges_fold
> > as per the current draft standard.
> 
> OK, but this needs RM approval to push to gcc-13

Ok, if you can commit it today.

> > libstdc++-v3/ChangeLog:
> >
> >         * include/bits/ranges_algo.h (__cpp_lib_ranges_contains):
> >         Define for C++23.
> >         (__cpp_lib_ranges_iota): Likewise.
> >         (__cpp_lib_ranges_find_last): Likewise.
> >         (__cpp_lib_fold): Rename to ...
> >         (__cpp_lib_ranges_fold): ... this.
> >         * include/std/version: As above.
> >         * testsuite/25_algorithms/fold_left/1.cc: Adjust after
> >         renaming __cpp_lib_fold.
> >         * testsuite/std/ranges/version_c++23.cc: Verify values
> >         of the above feature-test macros.

	Jakub


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-18  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17  3:45 [PATCH] libstdc++: Adding missing feature-test macros for C++23 ranges algos Patrick Palka
2023-04-18  8:56 ` Jonathan Wakely
2023-04-18  8:59   ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).