public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3770] libstdc++: Simplify C++20 poison pill overloads (P2602R2)
@ 2023-09-07  7:11 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-09-07  7:11 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:6854e3ac71209ac786b878ef4abe6856a50c221d

commit r14-3770-g6854e3ac71209ac786b878ef4abe6856a50c221d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Sep 6 13:36:02 2023 +0100

    libstdc++: Simplify C++20 poison pill overloads (P2602R2)
    
    This implements the C++23 change "Poison Pills are Too Toxic". This
    makes sense to do unconditionally for C++20, as the corner cases that it
    fixes are considered to be defects in the C++20 design (e.g. LWG3480 was
    needed to fix directory iterators because of these pills being too
    toxic).
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/iterator_concepts.h (__imove::iter_move): Define
            poison pill as deleted for consistency.
            (__access::begin): Replace with a single declaration.
            * include/bits/ranges_base.h (__access::end, __access::rbegin)
            (__access::rend, __access::size): Likewise.
            * include/bits/version.def (ranges): Update value for C++23.
            * include/bits/version.h: Regenerate.
            * libsupc++/compare (__compare): Add missing poison pill
            overloads.
            * testsuite/std/ranges/version_c++23.cc: Adjust expected value
            of __cpp_lib_ranges.
            * testsuite/std/ranges/access/p2602.cc: New test.

Diff:
---
 libstdc++-v3/include/bits/iterator_concepts.h      |  7 +++--
 libstdc++-v3/include/bits/ranges_base.h            | 14 ++++------
 libstdc++-v3/include/bits/version.def              |  2 +-
 libstdc++-v3/include/bits/version.h                |  4 +--
 libstdc++-v3/libsupc++/compare                     |  6 +++++
 libstdc++-v3/testsuite/std/ranges/access/p2602.cc  | 31 ++++++++++++++++++++++
 libstdc++-v3/testsuite/std/ranges/version_c++23.cc |  2 +-
 7 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index 869d52e378b8..3517663db9ac 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -100,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     /// @cond undocumented
     namespace __imove
     {
-      void iter_move();
+      void iter_move() = delete;
 
       template<typename _Tp>
 	concept __adl_imove
@@ -979,9 +979,8 @@ namespace ranges
 	  { __decay_copy(__t.begin()) } -> input_or_output_iterator;
 	};
 
-    // Poison pills so that unqualified lookup doesn't find std::begin.
-    void begin(auto&) = delete;
-    void begin(const auto&) = delete;
+    // Poison pill so that unqualified lookup doesn't find std::begin.
+    void begin() = delete;
 
     template<typename _Tp>
       concept __adl_begin = __class_or_enum<remove_reference_t<_Tp>>
diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index 35861755c0b1..7fa43d1965a2 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -133,9 +133,8 @@ namespace ranges
 	  { __decay_copy(__t.end()) } -> sentinel_for<__range_iter_t<_Tp>>;
 	};
 
-    // Poison pills so that unqualified lookup doesn't find std::end.
-    void end(auto&) = delete;
-    void end(const auto&) = delete;
+    // Poison pill so that unqualified lookup doesn't find std::end.
+    void end() = delete;
 
     template<typename _Tp>
       concept __adl_end = __class_or_enum<remove_reference_t<_Tp>>
@@ -184,8 +183,7 @@ namespace ranges
 	  { __decay_copy(__t.rbegin()) } -> input_or_output_iterator;
 	};
 
-    void rbegin(auto&) = delete;
-    void rbegin(const auto&) = delete;
+    void rbegin() = delete;
 
     template<typename _Tp>
       concept __adl_rbegin = __class_or_enum<remove_reference_t<_Tp>>
@@ -248,8 +246,7 @@ namespace ranges
 	    -> sentinel_for<decltype(_RBegin{}(std::forward<_Tp>(__t)))>;
 	};
 
-    void rend(auto&) = delete;
-    void rend(const auto&) = delete;
+    void rend() = delete;
 
     template<typename _Tp>
       concept __adl_rend = __class_or_enum<remove_reference_t<_Tp>>
@@ -306,8 +303,7 @@ namespace ranges
 	  { __decay_copy(__t.size()) } -> __detail::__is_integer_like;
 	};
 
-    void size(auto&) = delete;
-    void size(const auto&) = delete;
+    void size() = delete;
 
     template<typename _Tp>
       concept __adl_size = __class_or_enum<remove_reference_t<_Tp>>
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 44b916e38974..da8d067dd1ab 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -1045,7 +1045,7 @@ ftms = {
 ftms = {
   name = ranges;
   values = {
-    v = 202207;
+    v = 202211;
     cxxmin = 23;
     extra_cond = "__glibcxx_concepts";
   };
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 9fada98eee3f..22cc21119c56 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -1290,9 +1290,9 @@
 // from version.def line 1046
 #if !defined(__cpp_lib_ranges)
 # if (__cplusplus >= 202302L) && (__glibcxx_concepts)
-#  define __glibcxx_ranges 202207L
+#  define __glibcxx_ranges 202211L
 #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_ranges)
-#   define __cpp_lib_ranges 202207L
+#   define __cpp_lib_ranges 202211L
 #  endif
 # elif (__cplusplus >= 202002L) && (__glibcxx_concepts)
 #  define __glibcxx_ranges 202110L
diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index 84ef31a1ee71..51693794491b 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -612,6 +612,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 	  }
       }
 
+    void strong_order() = delete;
+
     template<typename _Tp, typename _Up>
       concept __adl_strong = requires(_Tp&& __t, _Up&& __u)
 	{
@@ -619,6 +621,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 				       static_cast<_Up&&>(__u)));
 	};
 
+    void weak_order() = delete;
+
     template<typename _Tp, typename _Up>
       concept __adl_weak = requires(_Tp&& __t, _Up&& __u)
 	{
@@ -626,6 +630,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 				   static_cast<_Up&&>(__u)));
 	};
 
+    void partial_order() = delete;
+
     template<typename _Tp, typename _Up>
       concept __adl_partial = requires(_Tp&& __t, _Up&& __u)
 	{
diff --git a/libstdc++-v3/testsuite/std/ranges/access/p2602.cc b/libstdc++-v3/testsuite/std/ranges/access/p2602.cc
new file mode 100644
index 000000000000..9c6a0e6ee95f
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/ranges/access/p2602.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+// P2602R2 Poison Pills are Too Toxic
+
+#include <ranges>
+
+struct A {
+    friend auto begin(A const&) -> int const*;
+    friend auto end(A const&)   -> int const*;
+};
+
+struct B {
+    friend auto begin(B&) -> int*;
+    friend auto end(B&) -> int*;
+};
+
+static_assert( std::ranges::range<A> );
+static_assert( std::ranges::range<const A> );
+static_assert( std::ranges::range<B> );
+static_assert( ! std::ranges::range<const B> );
+
+class Test {
+    friend size_t size(const Test&) {
+	return 0;
+    }
+};
+
+size_t f(Test t) {
+   return std::ranges::size(t);
+}
diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
index 8e4a8b466aab..64b7df409c90 100644
--- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
+++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
@@ -4,7 +4,7 @@
 #include <version>
 
 #if __STDC_HOSTED__
-# if __cpp_lib_ranges != 202207L
+# if __cpp_lib_ranges != 202211L
 #  error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
 # endif
 #endif

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-07  7:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07  7:11 [gcc r14-3770] libstdc++: Simplify C++20 poison pill overloads (P2602R2) 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).