aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-08-22 09:24:20 -0400
committerPatrick Palka <ppalka@redhat.com>2024-08-22 09:24:20 -0400
commit620232426bd83a79c81cd2be6f485834c618e920 (patch)
treeaa6bd5dbfdc57a613b2de3162672776cf481b99e /libstdc++-v3/testsuite
parentb552730faf36f1eae1dc6e73ccc93a016dec5401 (diff)
downloadgcc-620232426bd83a79c81cd2be6f485834c618e920.zip
gcc-620232426bd83a79c81cd2be6f485834c618e920.tar.gz
gcc-620232426bd83a79c81cd2be6f485834c618e920.tar.bz2
libstdc++: Implement P2997R1 changes to the indirect invocability concepts
This implements the changes of this C++26 paper as a DR against C++20. In passing this patch removes the std/ranges/version_c++23.cc test which is now mostly obsolete after the version.def FTM refactoring, and instead expands the __cpp_lib_ranges checks in another test so that it verifies the exact value of the FTM on a per language version basis. libstdc++-v3/ChangeLog: * include/bits/iterator_concepts.h (indirectly_unary_invocable): Relax as per P2997R1. (indirectly_regular_unary_invocable): Likewise. (indirect_unary_predicate): Likewise. (indirect_binary_predicate): Likewise. (indirect_equivalence_relation): Likewise. (indirect_strict_weak_order): Likewise. * include/bits/version.def (ranges): Update value for C++26. * include/bits/version.h: Regenerate. * testsuite/24_iterators/indirect_callable/p2997r1.cc: New test. * testsuite/std/ranges/version_c++23.cc: Remove. * testsuite/std/ranges/headers/ranges/synopsis.cc: Refine the __cpp_lib_ranges checks. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/24_iterators/indirect_callable/p2997r1.cc37
-rw-r--r--libstdc++-v3/testsuite/std/ranges/headers/ranges/synopsis.cc6
-rw-r--r--libstdc++-v3/testsuite/std/ranges/version_c++23.cc70
3 files changed, 42 insertions, 71 deletions
diff --git a/libstdc++-v3/testsuite/24_iterators/indirect_callable/p2997r1.cc b/libstdc++-v3/testsuite/24_iterators/indirect_callable/p2997r1.cc
new file mode 100644
index 0000000..6a66b0f
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/indirect_callable/p2997r1.cc
@@ -0,0 +1,37 @@
+// Test the example from P2997R1 "Removing the common reference requirement
+// from the indirectly invocable concepts".
+// { dg-do compile { target c++20 } }
+
+#include <algorithm>
+#include <ranges>
+
+struct C {
+ auto f() -> void;
+};
+
+struct Iterator {
+ using value_type = C;
+ using difference_type = std::ptrdiff_t;
+ using iterator_category = std::input_iterator_tag;
+
+ auto operator*() const -> C&&;
+ auto operator++() -> Iterator&;
+ auto operator++(int) -> void;
+ auto operator==(Iterator const&) const -> bool;
+};
+
+static_assert(std::input_iterator<Iterator>);
+static_assert(std::same_as<std::iter_value_t<Iterator>, C>);
+static_assert(std::same_as<std::iter_reference_t<Iterator>, C&&>);
+
+struct R {
+ auto begin() -> Iterator;
+ auto end() -> Iterator;
+};
+
+static_assert(std::ranges::range<R>);
+static_assert(std::same_as<std::ranges::range_reference_t<R>, C&&>);
+
+auto f(R r) -> void {
+ std::ranges::for_each(r, [](auto&& c){ c.f(); });
+}
diff --git a/libstdc++-v3/testsuite/std/ranges/headers/ranges/synopsis.cc b/libstdc++-v3/testsuite/std/ranges/headers/ranges/synopsis.cc
index 48f53b6..d359039 100644
--- a/libstdc++-v3/testsuite/std/ranges/headers/ranges/synopsis.cc
+++ b/libstdc++-v3/testsuite/std/ranges/headers/ranges/synopsis.cc
@@ -22,7 +22,11 @@
#ifndef __cpp_lib_ranges
# error "Feature test macro for ranges is missing in <ranges>"
-#elif __cpp_lib_ranges < 201911L
+#elif __cplusplus > 202302L && __cpp_lib_ranges != 202406L
+# error "Feature test macro for ranges has wrong value in <ranges>"
+#elif __cplusplus == 202302L && __cpp_lib_ranges != 202302L
+# error "Feature test macro for ranges has wrong value in <ranges>"
+#elif __cplusplus == 202002L && __cpp_lib_ranges != 202110L
# error "Feature test macro for ranges has wrong value in <ranges>"
#endif
diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
deleted file mode 100644
index 0187115..0000000
--- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// { dg-do preprocess { target c++23 } }
-// { dg-add-options no_pch }
-
-#include <version>
-
-#if __STDC_HOSTED__
-# if __cpp_lib_ranges != 202302L
-# error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
-# endif
-#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
-
-#if __cpp_lib_ranges_as_const != 202311L
-# error "Feature-test macro __cpp_lib_ranges_as_const has wrong value in <version>"
-#endif
-
-#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