public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Add feature-test macros for implemented C++23 views [PR108260]
@ 2023-01-06 14:59 Patrick Palka
  2023-01-06 15:07 ` Patrick Palka
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2023-01-06 14:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

	PR libstdc++/108620

libstdc++-v3/ChangeLog:

	* include/bits/utility.h (__cpp_lib_ranges_zip): Define.
	* include/std/ranges (__cpp_lib_ranges_zip): Define.
	(__cpp_lib_ranges_chunk): Define.
	(__cpp_lib_ranges_slide): Define.
	(__cpp_lib_ranges_chunk_by): Define.
	(__cpp_lib_ranges_join_with): Define.
	(__cpp_lib_ranges_repeat): Define.
	(__cpp_lib_ranges_stride): Define.
	(__cpp_lib_ranges_cartesian_product): Define.
	(__cpp_lib_ranges_as_rvalue): Define.
	* include/std/version: Likewise.
	* testsuite/20_util/tuple/p2321r2.cc: Test feature-test macro.
	* testsuite/std/ranges/adaptors/as_rvalue/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/join_with/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/slide/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/stride/1.cc: Likewise.
	* testsuite/std/ranges/cartesian_product/1.cc: Likewise.
	* testsuite/std/ranges/repeat/1.cc: Likewise.
	* testsuite/std/ranges/zip/1.cc: Likewise.
	* testsuite/std/ranges/version_c++23.cc: New test.
---
 libstdc++-v3/include/bits/utility.h           |  4 ++
 libstdc++-v3/include/std/ranges               | 19 ++++++++
 libstdc++-v3/include/std/version              |  9 ++++
 .../testsuite/20_util/tuple/p2321r2.cc        |  4 ++
 .../std/ranges/adaptors/as_rvalue/1.cc        |  4 ++
 .../testsuite/std/ranges/adaptors/chunk/1.cc  |  4 ++
 .../std/ranges/adaptors/chunk_by/1.cc         |  4 ++
 .../std/ranges/adaptors/join_with/1.cc        |  4 ++
 .../testsuite/std/ranges/adaptors/slide/1.cc  |  4 ++
 .../testsuite/std/ranges/adaptors/stride/1.cc |  4 ++
 .../std/ranges/cartesian_product/1.cc         |  4 ++
 libstdc++-v3/testsuite/std/ranges/repeat/1.cc |  4 ++
 .../testsuite/std/ranges/version_c++23.cc     | 44 +++++++++++++++++++
 libstdc++-v3/testsuite/std/ranges/zip/1.cc    |  4 ++
 14 files changed, 116 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/std/ranges/version_c++23.cc

diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
index 6a192e27836..fac6c7dc3bd 100644
--- a/libstdc++-v3/include/bits/utility.h
+++ b/libstdc++-v3/include/bits/utility.h
@@ -263,6 +263,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { using type = _Tp1; };
 #endif
 
+#if __cplusplus > 202002L
+#define __cpp_lib_ranges_zip 202110L // for <tuple> and <utility>
+#endif
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index ba544e116e1..dce7867e977 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -4364,6 +4364,9 @@ namespace views::__adaptor
   } // namespace views
 
 #if __cplusplus > 202002L
+
+#define __cpp_lib_ranges_zip 202110L
+
   namespace __detail
   {
     template<typename... _Rs>
@@ -5802,6 +5805,8 @@ namespace views::__adaptor
     inline constexpr auto pairwise_transform = adjacent_transform<2>;
   }
 
+#define __cpp_lib_ranges_chunk 202202L
+
   namespace __detail
   {
     template<typename _Tp>
@@ -6339,6 +6344,8 @@ namespace views::__adaptor
     inline constexpr _Chunk chunk;
   }
 
+#define __cpp_lib_ranges_slide 202202L
+
   namespace __detail
   {
     template<typename _Vp>
@@ -6702,6 +6709,8 @@ namespace views::__adaptor
     inline constexpr _Slide slide;
   }
 
+#define __cpp_lib_ranges_chunk_by 202202L
+
   template<forward_range _Vp,
 	   indirect_binary_predicate<iterator_t<_Vp>, iterator_t<_Vp>> _Pred>
     requires view<_Vp> && is_object_v<_Pred>
@@ -6895,6 +6904,8 @@ namespace views::__adaptor
     inline constexpr _ChunkBy chunk_by;
   }
 
+#define __cpp_lib_ranges_join_with 202202L
+
   namespace __detail
   {
     template<typename _Range, typename _Pattern>
@@ -7375,6 +7386,8 @@ namespace views::__adaptor
     inline constexpr _JoinWith join_with;
   } // namespace views
 
+#define __cpp_lib_ranges_repeat 202207L
+
   template<copy_constructible _Tp, semiregular _Bound = unreachable_sentinel_t>
     requires (is_object_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
       && (__detail::__is_integer_like<_Bound> || same_as<_Bound, unreachable_sentinel_t>))
@@ -7626,6 +7639,8 @@ namespace views::__adaptor
     }
   }
 
+#define __cpp_lib_ranges_stride 202207L
+
   template<input_range _Vp>
     requires view<_Vp>
   class stride_view : public view_interface<stride_view<_Vp>>
@@ -7977,6 +7992,8 @@ namespace views::__adaptor
     inline constexpr _Stride stride;
   }
 
+#define __cpp_lib_ranges_cartesian_product 202207L
+
   namespace __detail
   {
     template<bool _Const, typename _First, typename... _Vs>
@@ -8487,6 +8504,8 @@ namespace views::__adaptor
     inline constexpr _CartesianProduct cartesian_product;
   }
 
+#define __cpp_lib_ranges_as_rvalue 202207L
+
   template<input_range _Vp>
     requires view<_Vp>
   class as_rvalue_view : public view_interface<as_rvalue_view<_Vp>>
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index c1a9896b0c2..5730357793d 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -319,6 +319,15 @@
 #define __cpp_lib_reference_from_temporary 202202L
 #define __cpp_lib_to_underlying 202102L
 #define __cpp_lib_unreachable 202202L
+#define __cpp_lib_ranges_zip 202110L
+#define __cpp_lib_ranges_chunk 202202L
+#define __cpp_lib_ranges_slide 202202L
+#define __cpp_lib_ranges_chunk_by 202202L
+#define __cpp_lib_ranges_join_with 202202L
+#define __cpp_lib_ranges_repeat 202207L
+#define __cpp_lib_ranges_stride 202207L
+#define __cpp_lib_ranges_cartesian_product 202207L
+#define __cpp_lib_ranges_as_rvalue 202207L
 
 #if _GLIBCXX_HOSTED
 #define __cpp_lib_adaptor_iterator_pair_constructor 202106L
diff --git a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
index 04ac27358eb..ceed38b16ec 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
@@ -8,6 +8,10 @@
 #include <memory>
 #include <testsuite_hooks.h>
 
+#if __cpp_lib_ranges_zip != 202110L
+# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <tuple>"
+#endif
+
 using std::tuple;
 using std::pair;
 using std::allocator;
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
index 8ca4f50e9d2..fbf0d651366 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
@@ -7,6 +7,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_as_rvalue != 202207L
+# error "Feature-test macro __cpp_lib_ranges_as_rvalue has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
index 125c88ef853..18b934f99ee 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
@@ -7,6 +7,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_chunk != 202202L
+# error "Feature-test macro __cpp_lib_ranges_chunk has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
index d57b127fbc8..cba6fad6f9a 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
@@ -7,6 +7,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_chunk_by != 202202L
+# error "Feature-test macro __cpp_lib_ranges_chunk_by has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
index 8b9c6c4fc9f..15127c0715f 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
@@ -7,6 +7,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_join_with != 202202L
+# error "Feature-test macro __cpp_lib_ranges_join_with has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 using namespace std::literals;
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
index 98560420810..8c015c1162b 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
@@ -7,6 +7,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_slide != 202202L
+# error "Feature-test macro __cpp_lib_ranges_slide has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
index 37ae896014a..92aca35e83f 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
@@ -6,6 +6,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_stride != 202207L
+# error "Feature-test macro __cpp_lib_ranges_stride has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
index d6e4b538b20..1ec4422e6f3 100644
--- a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
@@ -6,6 +6,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_cartesian_product != 202207L
+# error "Feature-test macro __cpp_lib_ranges_cartesian_product has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
index f9817c99600..2f3ad4522a4 100644
--- a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
@@ -5,6 +5,10 @@
 #include <algorithm>
 #include <testsuite_hooks.h>
 
+#if __cpp_lib_ranges_repeat != 202207L
+# error "Feature-test macro __cpp_lib_ranges_repeat has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
new file mode 100644
index 00000000000..d9ea9eca6c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do preprocess { target c++23 } }
+
+#include <version>
+
+#if __cpp_lib_ranges != 202110L
+# error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_zip != 202110L
+# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_chunk != 202202L
+# error "Feature-test macro __cpp_lib_ranges_chunk has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_slide != 202202L
+# error "Feature-test macro __cpp_lib_ranges_slide has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_chunk_by != 202202L
+# error "Feature-test macro __cpp_lib_ranges_chunk_by has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_join_with != 202202L
+# error "Feature-test macro __cpp_lib_ranges_join_with has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_repeat != 202207L
+# error "Feature-test macro __cpp_lib_ranges_repeat has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_stride != 202207L
+# error "Feature-test macro __cpp_lib_ranges_stride has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_cartesian_product != 202207L
+# error "Feature-test macro __cpp_lib_ranges_cartesian_product has wrong value in <version>"
+#endif
+
+#if __cpp_lib_ranges_as_rvalue != 202207L
+# error "Feature-test macro __cpp_lib_ranges_as_rvalue has wrong value in <version>"
+#endif
diff --git a/libstdc++-v3/testsuite/std/ranges/zip/1.cc b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
index e9e40fb15eb..8ca386d6563 100644
--- a/libstdc++-v3/testsuite/std/ranges/zip/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
@@ -8,6 +8,10 @@
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#if __cpp_lib_ranges_zip != 202110L
+# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <ranges>"
+#endif
+
 namespace ranges = std::ranges;
 namespace views = std::views;
 
-- 
2.39.0.189.g4dbebc36b0


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

* Re: [PATCH] libstdc++: Add feature-test macros for implemented C++23 views [PR108260]
  2023-01-06 14:59 [PATCH] libstdc++: Add feature-test macros for implemented C++23 views [PR108260] Patrick Palka
@ 2023-01-06 15:07 ` Patrick Palka
  2023-01-06 15:22   ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2023-01-06 15:07 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On Fri, 6 Jan 2023, Patrick Palka wrote:

> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> 
> 	PR libstdc++/108620
> 
> libstdc++-v3/ChangeLog:
> 
> 	* include/bits/utility.h (__cpp_lib_ranges_zip): Define.
> 	* include/std/ranges (__cpp_lib_ranges_zip): Define.
> 	(__cpp_lib_ranges_chunk): Define.
> 	(__cpp_lib_ranges_slide): Define.
> 	(__cpp_lib_ranges_chunk_by): Define.
> 	(__cpp_lib_ranges_join_with): Define.
> 	(__cpp_lib_ranges_repeat): Define.
> 	(__cpp_lib_ranges_stride): Define.
> 	(__cpp_lib_ranges_cartesian_product): Define.
> 	(__cpp_lib_ranges_as_rvalue): Define.
> 	* include/std/version: Likewise.
> 	* testsuite/20_util/tuple/p2321r2.cc: Test feature-test macro.
> 	* testsuite/std/ranges/adaptors/as_rvalue/1.cc: Likewise.
> 	* testsuite/std/ranges/adaptors/chunk/1.cc: Likewise.
> 	* testsuite/std/ranges/adaptors/chunk_by/1.cc: Likewise.
> 	* testsuite/std/ranges/adaptors/join_with/1.cc: Likewise.
> 	* testsuite/std/ranges/adaptors/slide/1.cc: Likewise.
> 	* testsuite/std/ranges/adaptors/stride/1.cc: Likewise.
> 	* testsuite/std/ranges/cartesian_product/1.cc: Likewise.
> 	* testsuite/std/ranges/repeat/1.cc: Likewise.
> 	* testsuite/std/ranges/zip/1.cc: Likewise.
> 	* testsuite/std/ranges/version_c++23.cc: New test.
> ---
>  libstdc++-v3/include/bits/utility.h           |  4 ++
>  libstdc++-v3/include/std/ranges               | 19 ++++++++
>  libstdc++-v3/include/std/version              |  9 ++++
>  .../testsuite/20_util/tuple/p2321r2.cc        |  4 ++
>  .../std/ranges/adaptors/as_rvalue/1.cc        |  4 ++
>  .../testsuite/std/ranges/adaptors/chunk/1.cc  |  4 ++
>  .../std/ranges/adaptors/chunk_by/1.cc         |  4 ++
>  .../std/ranges/adaptors/join_with/1.cc        |  4 ++
>  .../testsuite/std/ranges/adaptors/slide/1.cc  |  4 ++
>  .../testsuite/std/ranges/adaptors/stride/1.cc |  4 ++
>  .../std/ranges/cartesian_product/1.cc         |  4 ++
>  libstdc++-v3/testsuite/std/ranges/repeat/1.cc |  4 ++
>  .../testsuite/std/ranges/version_c++23.cc     | 44 +++++++++++++++++++
>  libstdc++-v3/testsuite/std/ranges/zip/1.cc    |  4 ++
>  14 files changed, 116 insertions(+)
>  create mode 100644 libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> 
> diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
> index 6a192e27836..fac6c7dc3bd 100644
> --- a/libstdc++-v3/include/bits/utility.h
> +++ b/libstdc++-v3/include/bits/utility.h
> @@ -263,6 +263,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      { using type = _Tp1; };
>  #endif
>  
> +#if __cplusplus > 202002L
> +#define __cpp_lib_ranges_zip 202110L // for <tuple> and <utility>
> +#endif
> +
>  _GLIBCXX_END_NAMESPACE_VERSION
>  } // namespace
>  
> diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
> index ba544e116e1..dce7867e977 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -4364,6 +4364,9 @@ namespace views::__adaptor
>    } // namespace views
>  
>  #if __cplusplus > 202002L
> +
> +#define __cpp_lib_ranges_zip 202110L
> +
>    namespace __detail
>    {
>      template<typename... _Rs>
> @@ -5802,6 +5805,8 @@ namespace views::__adaptor
>      inline constexpr auto pairwise_transform = adjacent_transform<2>;
>    }
>  
> +#define __cpp_lib_ranges_chunk 202202L
> +
>    namespace __detail
>    {
>      template<typename _Tp>
> @@ -6339,6 +6344,8 @@ namespace views::__adaptor
>      inline constexpr _Chunk chunk;
>    }
>  
> +#define __cpp_lib_ranges_slide 202202L
> +
>    namespace __detail
>    {
>      template<typename _Vp>
> @@ -6702,6 +6709,8 @@ namespace views::__adaptor
>      inline constexpr _Slide slide;
>    }
>  
> +#define __cpp_lib_ranges_chunk_by 202202L
> +
>    template<forward_range _Vp,
>  	   indirect_binary_predicate<iterator_t<_Vp>, iterator_t<_Vp>> _Pred>
>      requires view<_Vp> && is_object_v<_Pred>
> @@ -6895,6 +6904,8 @@ namespace views::__adaptor
>      inline constexpr _ChunkBy chunk_by;
>    }
>  
> +#define __cpp_lib_ranges_join_with 202202L
> +
>    namespace __detail
>    {
>      template<typename _Range, typename _Pattern>
> @@ -7375,6 +7386,8 @@ namespace views::__adaptor
>      inline constexpr _JoinWith join_with;
>    } // namespace views
>  
> +#define __cpp_lib_ranges_repeat 202207L
> +
>    template<copy_constructible _Tp, semiregular _Bound = unreachable_sentinel_t>
>      requires (is_object_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
>        && (__detail::__is_integer_like<_Bound> || same_as<_Bound, unreachable_sentinel_t>))
> @@ -7626,6 +7639,8 @@ namespace views::__adaptor
>      }
>    }
>  
> +#define __cpp_lib_ranges_stride 202207L
> +
>    template<input_range _Vp>
>      requires view<_Vp>
>    class stride_view : public view_interface<stride_view<_Vp>>
> @@ -7977,6 +7992,8 @@ namespace views::__adaptor
>      inline constexpr _Stride stride;
>    }
>  
> +#define __cpp_lib_ranges_cartesian_product 202207L
> +
>    namespace __detail
>    {
>      template<bool _Const, typename _First, typename... _Vs>
> @@ -8487,6 +8504,8 @@ namespace views::__adaptor
>      inline constexpr _CartesianProduct cartesian_product;
>    }
>  
> +#define __cpp_lib_ranges_as_rvalue 202207L
> +
>    template<input_range _Vp>
>      requires view<_Vp>
>    class as_rvalue_view : public view_interface<as_rvalue_view<_Vp>>
> diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
> index c1a9896b0c2..5730357793d 100644
> --- a/libstdc++-v3/include/std/version
> +++ b/libstdc++-v3/include/std/version
> @@ -319,6 +319,15 @@
>  #define __cpp_lib_reference_from_temporary 202202L
>  #define __cpp_lib_to_underlying 202102L
>  #define __cpp_lib_unreachable 202202L
> +#define __cpp_lib_ranges_zip 202110L
> +#define __cpp_lib_ranges_chunk 202202L
> +#define __cpp_lib_ranges_slide 202202L
> +#define __cpp_lib_ranges_chunk_by 202202L
> +#define __cpp_lib_ranges_join_with 202202L
> +#define __cpp_lib_ranges_repeat 202207L
> +#define __cpp_lib_ranges_stride 202207L
> +#define __cpp_lib_ranges_cartesian_product 202207L
> +#define __cpp_lib_ranges_as_rvalue 202207L

I should mention that these definitions in <version> aren't guarded by
__cpp_concepts, unlike e.g. __cpp_lib_expected and __cpp_lib_optional.
It is reasonable to assume __cpp_concepts is always defined for C++23
here?

>  
>  #if _GLIBCXX_HOSTED
>  #define __cpp_lib_adaptor_iterator_pair_constructor 202106L
> diff --git a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
> index 04ac27358eb..ceed38b16ec 100644
> --- a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
> +++ b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
> @@ -8,6 +8,10 @@
>  #include <memory>
>  #include <testsuite_hooks.h>
>  
> +#if __cpp_lib_ranges_zip != 202110L
> +# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <tuple>"
> +#endif
> +
>  using std::tuple;
>  using std::pair;
>  using std::allocator;
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
> index 8ca4f50e9d2..fbf0d651366 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
> @@ -7,6 +7,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_as_rvalue != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_as_rvalue has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
> index 125c88ef853..18b934f99ee 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
> @@ -7,6 +7,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_chunk != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_chunk has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
> index d57b127fbc8..cba6fad6f9a 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
> @@ -7,6 +7,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_chunk_by != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_chunk_by has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
> index 8b9c6c4fc9f..15127c0715f 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
> @@ -7,6 +7,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_join_with != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_join_with has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  using namespace std::literals;
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
> index 98560420810..8c015c1162b 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
> @@ -7,6 +7,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_slide != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_slide has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> index 37ae896014a..92aca35e83f 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> @@ -6,6 +6,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_stride != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_stride has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
> index d6e4b538b20..1ec4422e6f3 100644
> --- a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
> @@ -6,6 +6,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_cartesian_product != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_cartesian_product has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
> index f9817c99600..2f3ad4522a4 100644
> --- a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
> @@ -5,6 +5,10 @@
>  #include <algorithm>
>  #include <testsuite_hooks.h>
>  
> +#if __cpp_lib_ranges_repeat != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_repeat has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> new file mode 100644
> index 00000000000..d9ea9eca6c7
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> @@ -0,0 +1,44 @@
> +// { dg-options "-std=gnu++23" }
> +// { dg-do preprocess { target c++23 } }
> +
> +#include <version>
> +
> +#if __cpp_lib_ranges != 202110L
> +# error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_zip != 202110L
> +# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_chunk != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_chunk has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_slide != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_slide has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_chunk_by != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_chunk_by has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_join_with != 202202L
> +# error "Feature-test macro __cpp_lib_ranges_join_with has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_repeat != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_repeat has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_stride != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_stride has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_cartesian_product != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_cartesian_product has wrong value in <version>"
> +#endif
> +
> +#if __cpp_lib_ranges_as_rvalue != 202207L
> +# error "Feature-test macro __cpp_lib_ranges_as_rvalue has wrong value in <version>"
> +#endif
> diff --git a/libstdc++-v3/testsuite/std/ranges/zip/1.cc b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> index e9e40fb15eb..8ca386d6563 100644
> --- a/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> @@ -8,6 +8,10 @@
>  #include <testsuite_hooks.h>
>  #include <testsuite_iterators.h>
>  
> +#if __cpp_lib_ranges_zip != 202110L
> +# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <ranges>"
> +#endif
> +
>  namespace ranges = std::ranges;
>  namespace views = std::views;
>  
> -- 
> 2.39.0.189.g4dbebc36b0
> 
> 


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

* Re: [PATCH] libstdc++: Add feature-test macros for implemented C++23 views [PR108260]
  2023-01-06 15:07 ` Patrick Palka
@ 2023-01-06 15:22   ` Jonathan Wakely
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2023-01-06 15:22 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On Fri, 6 Jan 2023 at 15:07, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On Fri, 6 Jan 2023, Patrick Palka wrote:
>
> > Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> >
> >       PR libstdc++/108620
> >
> > libstdc++-v3/ChangeLog:
> >
> >       * include/bits/utility.h (__cpp_lib_ranges_zip): Define.
> >       * include/std/ranges (__cpp_lib_ranges_zip): Define.
> >       (__cpp_lib_ranges_chunk): Define.
> >       (__cpp_lib_ranges_slide): Define.
> >       (__cpp_lib_ranges_chunk_by): Define.
> >       (__cpp_lib_ranges_join_with): Define.
> >       (__cpp_lib_ranges_repeat): Define.
> >       (__cpp_lib_ranges_stride): Define.
> >       (__cpp_lib_ranges_cartesian_product): Define.
> >       (__cpp_lib_ranges_as_rvalue): Define.
> >       * include/std/version: Likewise.
> >       * testsuite/20_util/tuple/p2321r2.cc: Test feature-test macro.
> >       * testsuite/std/ranges/adaptors/as_rvalue/1.cc: Likewise.
> >       * testsuite/std/ranges/adaptors/chunk/1.cc: Likewise.
> >       * testsuite/std/ranges/adaptors/chunk_by/1.cc: Likewise.
> >       * testsuite/std/ranges/adaptors/join_with/1.cc: Likewise.
> >       * testsuite/std/ranges/adaptors/slide/1.cc: Likewise.
> >       * testsuite/std/ranges/adaptors/stride/1.cc: Likewise.
> >       * testsuite/std/ranges/cartesian_product/1.cc: Likewise.
> >       * testsuite/std/ranges/repeat/1.cc: Likewise.
> >       * testsuite/std/ranges/zip/1.cc: Likewise.
> >       * testsuite/std/ranges/version_c++23.cc: New test.
> > ---
> >  libstdc++-v3/include/bits/utility.h           |  4 ++
> >  libstdc++-v3/include/std/ranges               | 19 ++++++++
> >  libstdc++-v3/include/std/version              |  9 ++++
> >  .../testsuite/20_util/tuple/p2321r2.cc        |  4 ++
> >  .../std/ranges/adaptors/as_rvalue/1.cc        |  4 ++
> >  .../testsuite/std/ranges/adaptors/chunk/1.cc  |  4 ++
> >  .../std/ranges/adaptors/chunk_by/1.cc         |  4 ++
> >  .../std/ranges/adaptors/join_with/1.cc        |  4 ++
> >  .../testsuite/std/ranges/adaptors/slide/1.cc  |  4 ++
> >  .../testsuite/std/ranges/adaptors/stride/1.cc |  4 ++
> >  .../std/ranges/cartesian_product/1.cc         |  4 ++
> >  libstdc++-v3/testsuite/std/ranges/repeat/1.cc |  4 ++
> >  .../testsuite/std/ranges/version_c++23.cc     | 44 +++++++++++++++++++
> >  libstdc++-v3/testsuite/std/ranges/zip/1.cc    |  4 ++
> >  14 files changed, 116 insertions(+)
> >  create mode 100644 libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> >
> > diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
> > index 6a192e27836..fac6c7dc3bd 100644
> > --- a/libstdc++-v3/include/bits/utility.h
> > +++ b/libstdc++-v3/include/bits/utility.h
> > @@ -263,6 +263,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >      { using type = _Tp1; };
> >  #endif
> >
> > +#if __cplusplus > 202002L
> > +#define __cpp_lib_ranges_zip 202110L // for <tuple> and <utility>
> > +#endif
> > +
> >  _GLIBCXX_END_NAMESPACE_VERSION
> >  } // namespace
> >
> > diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
> > index ba544e116e1..dce7867e977 100644
> > --- a/libstdc++-v3/include/std/ranges
> > +++ b/libstdc++-v3/include/std/ranges
> > @@ -4364,6 +4364,9 @@ namespace views::__adaptor
> >    } // namespace views
> >
> >  #if __cplusplus > 202002L
> > +
> > +#define __cpp_lib_ranges_zip 202110L
> > +
> >    namespace __detail
> >    {
> >      template<typename... _Rs>
> > @@ -5802,6 +5805,8 @@ namespace views::__adaptor
> >      inline constexpr auto pairwise_transform = adjacent_transform<2>;
> >    }
> >
> > +#define __cpp_lib_ranges_chunk 202202L
> > +
> >    namespace __detail
> >    {
> >      template<typename _Tp>
> > @@ -6339,6 +6344,8 @@ namespace views::__adaptor
> >      inline constexpr _Chunk chunk;
> >    }
> >
> > +#define __cpp_lib_ranges_slide 202202L
> > +
> >    namespace __detail
> >    {
> >      template<typename _Vp>
> > @@ -6702,6 +6709,8 @@ namespace views::__adaptor
> >      inline constexpr _Slide slide;
> >    }
> >
> > +#define __cpp_lib_ranges_chunk_by 202202L
> > +
> >    template<forward_range _Vp,
> >          indirect_binary_predicate<iterator_t<_Vp>, iterator_t<_Vp>> _Pred>
> >      requires view<_Vp> && is_object_v<_Pred>
> > @@ -6895,6 +6904,8 @@ namespace views::__adaptor
> >      inline constexpr _ChunkBy chunk_by;
> >    }
> >
> > +#define __cpp_lib_ranges_join_with 202202L
> > +
> >    namespace __detail
> >    {
> >      template<typename _Range, typename _Pattern>
> > @@ -7375,6 +7386,8 @@ namespace views::__adaptor
> >      inline constexpr _JoinWith join_with;
> >    } // namespace views
> >
> > +#define __cpp_lib_ranges_repeat 202207L
> > +
> >    template<copy_constructible _Tp, semiregular _Bound = unreachable_sentinel_t>
> >      requires (is_object_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
> >        && (__detail::__is_integer_like<_Bound> || same_as<_Bound, unreachable_sentinel_t>))
> > @@ -7626,6 +7639,8 @@ namespace views::__adaptor
> >      }
> >    }
> >
> > +#define __cpp_lib_ranges_stride 202207L
> > +
> >    template<input_range _Vp>
> >      requires view<_Vp>
> >    class stride_view : public view_interface<stride_view<_Vp>>
> > @@ -7977,6 +7992,8 @@ namespace views::__adaptor
> >      inline constexpr _Stride stride;
> >    }
> >
> > +#define __cpp_lib_ranges_cartesian_product 202207L
> > +
> >    namespace __detail
> >    {
> >      template<bool _Const, typename _First, typename... _Vs>
> > @@ -8487,6 +8504,8 @@ namespace views::__adaptor
> >      inline constexpr _CartesianProduct cartesian_product;
> >    }
> >
> > +#define __cpp_lib_ranges_as_rvalue 202207L
> > +
> >    template<input_range _Vp>
> >      requires view<_Vp>
> >    class as_rvalue_view : public view_interface<as_rvalue_view<_Vp>>
> > diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
> > index c1a9896b0c2..5730357793d 100644
> > --- a/libstdc++-v3/include/std/version
> > +++ b/libstdc++-v3/include/std/version
> > @@ -319,6 +319,15 @@
> >  #define __cpp_lib_reference_from_temporary 202202L
> >  #define __cpp_lib_to_underlying 202102L
> >  #define __cpp_lib_unreachable 202202L
> > +#define __cpp_lib_ranges_zip 202110L
> > +#define __cpp_lib_ranges_chunk 202202L
> > +#define __cpp_lib_ranges_slide 202202L
> > +#define __cpp_lib_ranges_chunk_by 202202L
> > +#define __cpp_lib_ranges_join_with 202202L
> > +#define __cpp_lib_ranges_repeat 202207L
> > +#define __cpp_lib_ranges_stride 202207L
> > +#define __cpp_lib_ranges_cartesian_product 202207L
> > +#define __cpp_lib_ranges_as_rvalue 202207L
>
> I should mention that these definitions in <version> aren't guarded by
> __cpp_concepts, unlike e.g. __cpp_lib_expected and __cpp_lib_optional.
> It is reasonable to assume __cpp_concepts is always defined for C++23
> here?

Yes, I think I've already assumed that elsewhere (std::expected maybe?)

OK for trunk, thanks.


>
> >
> >  #if _GLIBCXX_HOSTED
> >  #define __cpp_lib_adaptor_iterator_pair_constructor 202106L
> > diff --git a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
> > index 04ac27358eb..ceed38b16ec 100644
> > --- a/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
> > +++ b/libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
> > @@ -8,6 +8,10 @@
> >  #include <memory>
> >  #include <testsuite_hooks.h>
> >
> > +#if __cpp_lib_ranges_zip != 202110L
> > +# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <tuple>"
> > +#endif
> > +
> >  using std::tuple;
> >  using std::pair;
> >  using std::allocator;
> > diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
> > index 8ca4f50e9d2..fbf0d651366 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
> > @@ -7,6 +7,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_as_rvalue != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_as_rvalue has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
> > index 125c88ef853..18b934f99ee 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
> > @@ -7,6 +7,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_chunk != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_chunk has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
> > index d57b127fbc8..cba6fad6f9a 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
> > @@ -7,6 +7,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_chunk_by != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_chunk_by has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
> > index 8b9c6c4fc9f..15127c0715f 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
> > @@ -7,6 +7,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_join_with != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_join_with has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >  using namespace std::literals;
> > diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
> > index 98560420810..8c015c1162b 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
> > @@ -7,6 +7,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_slide != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_slide has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> > index 37ae896014a..92aca35e83f 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> > @@ -6,6 +6,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_stride != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_stride has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
> > index d6e4b538b20..1ec4422e6f3 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
> > @@ -6,6 +6,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_cartesian_product != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_cartesian_product has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
> > index f9817c99600..2f3ad4522a4 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
> > @@ -5,6 +5,10 @@
> >  #include <algorithm>
> >  #include <testsuite_hooks.h>
> >
> > +#if __cpp_lib_ranges_repeat != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_repeat has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> > new file mode 100644
> > index 00000000000..d9ea9eca6c7
> > --- /dev/null
> > +++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
> > @@ -0,0 +1,44 @@
> > +// { dg-options "-std=gnu++23" }
> > +// { dg-do preprocess { target c++23 } }
> > +
> > +#include <version>
> > +
> > +#if __cpp_lib_ranges != 202110L
> > +# error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_zip != 202110L
> > +# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_chunk != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_chunk has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_slide != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_slide has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_chunk_by != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_chunk_by has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_join_with != 202202L
> > +# error "Feature-test macro __cpp_lib_ranges_join_with has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_repeat != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_repeat has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_stride != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_stride has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_cartesian_product != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_cartesian_product has wrong value in <version>"
> > +#endif
> > +
> > +#if __cpp_lib_ranges_as_rvalue != 202207L
> > +# error "Feature-test macro __cpp_lib_ranges_as_rvalue has wrong value in <version>"
> > +#endif
> > diff --git a/libstdc++-v3/testsuite/std/ranges/zip/1.cc b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> > index e9e40fb15eb..8ca386d6563 100644
> > --- a/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> > +++ b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> > @@ -8,6 +8,10 @@
> >  #include <testsuite_hooks.h>
> >  #include <testsuite_iterators.h>
> >
> > +#if __cpp_lib_ranges_zip != 202110L
> > +# error "Feature-test macro __cpp_lib_ranges_zip has wrong value in <ranges>"
> > +#endif
> > +
> >  namespace ranges = std::ranges;
> >  namespace views = std::views;
> >
> > --
> > 2.39.0.189.g4dbebc36b0
> >
> >
>


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

end of thread, other threads:[~2023-01-06 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 14:59 [PATCH] libstdc++: Add feature-test macros for implemented C++23 views [PR108260] Patrick Palka
2023-01-06 15:07 ` Patrick Palka
2023-01-06 15:22   ` Jonathan Wakely

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).