]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add feature-test macros for implemented C++23 views [PR108260]
authorPatrick Palka <ppalka@redhat.com>
Fri, 6 Jan 2023 15:32:10 +0000 (10:32 -0500)
committerPatrick Palka <ppalka@redhat.com>
Fri, 6 Jan 2023 15:32:10 +0000 (10:32 -0500)
PR libstdc++/108260

libstdc++-v3/ChangeLog:

* include/bits/utility.h (__cpp_lib_ranges_zip): Define for C++23.
* include/std/ranges (__cpp_lib_ranges_zip): Likewise.
(__cpp_lib_ranges_chunk): Likewise.
(__cpp_lib_ranges_slide): Likewise.
(__cpp_lib_ranges_chunk_by): Likewise.
(__cpp_lib_ranges_join_with): Likewise.
(__cpp_lib_ranges_repeat): Likewise.
(__cpp_lib_ranges_stride): Likewise.
(__cpp_lib_ranges_cartesian_product): Likewise.
(__cpp_lib_ranges_as_rvalue): Likewise.
* include/std/version: Ditto.
* testsuite/20_util/tuple/p2321r2.cc: Verify value of
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.

14 files changed:
libstdc++-v3/include/bits/utility.h
libstdc++-v3/include/std/ranges
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/20_util/tuple/p2321r2.cc
libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
libstdc++-v3/testsuite/std/ranges/adaptors/chunk/1.cc
libstdc++-v3/testsuite/std/ranges/adaptors/chunk_by/1.cc
libstdc++-v3/testsuite/std/ranges/adaptors/join_with/1.cc
libstdc++-v3/testsuite/std/ranges/adaptors/slide/1.cc
libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc
libstdc++-v3/testsuite/std/ranges/repeat/1.cc
libstdc++-v3/testsuite/std/ranges/version_c++23.cc [new file with mode: 0644]
libstdc++-v3/testsuite/std/ranges/zip/1.cc

index 6a192e278366132a90547e1e583348235710d244..fac6c7dc3bd106030e245b05bbbc198b3b69628e 100644 (file)
@@ -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
 
index ba544e116e14bec8d70e2e2e00e1907badf39891..dce7867e97749b14085f64f27ee3842d6bd7a516 100644 (file)
@@ -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>>
index c1a9896b0c228fffbbbd7465420bbdf636a0397f..5730357793dd1f0831bd4cca4f253ab045022d75 100644 (file)
 #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
index 04ac27358eb33b5fb1d0694a05c3b10dc72a36e5..ceed38b16ec8a6ed6f443d92232fcdb91763f59d 100644 (file)
@@ -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;
index 8ca4f50e9d25c69194fec5af1c781da248b3e629..fbf0d6513660a129134b7db7d73e6badd0ea30ae 100644 (file)
@@ -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;
 
index 125c88ef853d284694e44baf939981f5cfe98f58..18b934f99ee4c63e8b0f35a1db6847054189ca8a 100644 (file)
@@ -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;
 
index d57b127fbc8d7b4c924be53722f8745ab524194d..cba6fad6f9a8eec8887974506cd0cc0186e17a8e 100644 (file)
@@ -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;
 
index 8b9c6c4fc9f91da9c4e782889962ce7735179370..15127c0715f949ab90677ff5cd35a6921071e990 100644 (file)
@@ -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;
index 98560420810537088cdf71fea0b9a4191ca18d7e..8c015c1162b57f512f30f76a4fc9208b057d8ecb 100644 (file)
@@ -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;
 
index 37ae896014a5f526e2004d46483e4273dcbc0898..92aca35e83f0599e24835c1f163163fb4aa96269 100644 (file)
@@ -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;
 
index d6e4b538b20bc48c433dbe421bab02715e57c439..1ec4422e6f3acf5996ee1923a83c3ed598a64248 100644 (file)
@@ -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;
 
index f9817c99600aadc7d68f62a1be55771aacde1647..2f3ad4522a40d51990f75aad3f94c516d634e419 100644 (file)
@@ -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 (file)
index 0000000..d9ea9ec
--- /dev/null
@@ -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
index e9e40fb15eb7af850cdba526b2829bf7ad43f7d9..8ca386d65632a91f311c57014e8f4fd586cf5915 100644 (file)
@@ -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;