[committed] libstdc++: Implement LWG issues 3329, 3331, 3360, 3364, 3385

Message ID 20200219221318.GR9441@redhat.com
State New
Headers show
Series
  • [committed] libstdc++: Implement LWG issues 3329, 3331, 3360, 3364, 3385
Related show

Commit Message

Jonathan Wakely Feb. 19, 2020, 10:13 p.m.
make common_iterator<I, S> require copyable<I> (LWG 3385)
Add default-initializers to views (LWG 3364)
Simplify std::three_way_comparable_with (LWG 3360)
Simplify std::totally_ordered (LWG 3331)
Simplify std::totally_ordered_with (LWG 3329)

Tested powerpc64le-linux, committed to master.

Patch

commit 1b425f3ac516f7250e9f7eac7cd4fe0908ccfa4e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 19 21:56:29 2020 +0000

    libstdc++: make common_iterator<I, S> require copyable<I> (LWG 3385)
    
            * include/bits/stl_iterator.h (common_iterator): Add copyable<I>
            requirement (LWG 3385).
            * testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: Adjust
            expected declaration.

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ef91b80ef45..7f3f8876957 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@ 
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+	* include/bits/stl_iterator.h (common_iterator): Add copyable<I>
+	requirement (LWG 3385).
+	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: Adjust
+	expected declaration.
+
 	* include/std/ranges (take_while_view, drop_view, drop_while_view)
 	(elements_view:_Iterator): Initialize data members (LWG 3364).
 
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index fc9d442b475..372df223113 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1426,7 +1426,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// An iterator/sentinel adaptor for representing a non-common range.
   template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
-    requires (!same_as<_It, _Sent>)
+    requires (!same_as<_It, _Sent>) && copyable<_It>
   class common_iterator
   {
     template<typename _Tp, typename _Up>
diff --git a/libstdc++-v3/testsuite/24_iterators/headers/iterator/synopsis_c++20.cc b/libstdc++-v3/testsuite/24_iterators/headers/iterator/synopsis_c++20.cc
index 4d8eca31d38..fbe116be2fd 100644
--- a/libstdc++-v3/testsuite/24_iterators/headers/iterator/synopsis_c++20.cc
+++ b/libstdc++-v3/testsuite/24_iterators/headers/iterator/synopsis_c++20.cc
@@ -56,7 +56,7 @@  namespace std
   template<semiregular S> class move_sentinel;
 
   template<input_or_output_iterator I, sentinel_for<I> S>
-    requires (!same_as<I, S>)
+    requires (!same_as<I, S>) && copyable<I>
     class common_iterator;
 
   template<class I, class S>

commit 7433536b3d864c0d8d5180348690e1c280a3eaf2
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 19 22:00:14 2020 +0000

    libstdc++: Add default-initializers to views (LWG 3364)
    
            * include/std/ranges (take_while_view, drop_view, drop_while_view)
            (elements_view:_Iterator): Initialize data members (LWG 3364).

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 622c2948eab..ef91b80ef45 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,8 @@ 
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+	* include/std/ranges (take_while_view, drop_view, drop_while_view)
+	(elements_view:_Iterator): Initialize data members (LWG 3364).
+
 	* libsupc++/compare (three_way_comparable): Remove always-false check
 	that should have been removed with weak_equality (P1959R0).
 	(three_way_comparable_with): Likewise. Reorder requirements (LWG 3360).
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index b348ba2cfcb..7a66491f2e4 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2008,7 +2008,7 @@  namespace views
 	  { return __y._M_end == __x || !std::__invoke(*__y._M_pred, *__x); }
 	};
 
-      _Vp _M_base;
+      _Vp _M_base = _Vp();
       __detail::__box<_Pred> _M_pred;
 
     public:
@@ -2068,8 +2068,8 @@  namespace views
     class drop_view : public view_interface<drop_view<_Vp>>
     {
     private:
-      _Vp _M_base;
-      range_difference_t<_Vp> _M_count;
+      _Vp _M_base = _Vp();
+      range_difference_t<_Vp> _M_count = 0;
 
     public:
       drop_view() = default;
@@ -2147,7 +2147,7 @@  namespace views
     class drop_while_view : public view_interface<drop_while_view<_Vp, _Pred>>
     {
     private:
-      _Vp _M_base;
+      _Vp _M_base = _Vp();
       __detail::__box<_Pred> _M_pred;
 
     public:
@@ -3179,7 +3179,7 @@  namespace views
 	{
 	  using _Base = conditional_t<_Const, const _Vp, _Vp>;
 
-	  iterator_t<_Base> _M_current;
+	  iterator_t<_Base> _M_current = iterator_t<_Base>();
 
 	  friend _Iterator<!_Const>;
 

commit 256f67aa078de0e7bf53a0870c2cb87ab90cda09
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 19 21:45:59 2020 +0000

    libstdc++: Simplify std::three_way_comparable_with (LWG 3360)
    
    This also removes a useless condition that was supposed to be removed by
    the P1959R0 changes, but left in when that was implemented.
    
            * libsupc++/compare (three_way_comparable): Remove always-false check
            that should have been removed with weak_equality (P1959R0).
            (three_way_comparable_with): Likewise. Reorder requirements (LWG 3360).

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 1711a359256..622c2948eab 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,9 @@ 
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+	* libsupc++/compare (three_way_comparable): Remove always-false check
+	that should have been removed with weak_equality (P1959R0).
+	(three_way_comparable_with): Likewise. Reorder requirements (LWG 3360).
+
 	* include/std/concepts (__detail::__partially_ordered_with): Move here
 	from <compare>.
 	(totally_ordered, totally_ordered_with): Use __partially_ordered_with
diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index a74ebc845bf..b88b691b9e1 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -417,8 +417,7 @@  namespace std
   template<typename _Tp, typename _Cat = partial_ordering>
     concept three_way_comparable
       = __detail::__weakly_eq_cmp_with<_Tp, _Tp>
-      && (!convertible_to<_Cat, partial_ordering>
-	  || __detail::__partially_ordered_with<_Tp, _Tp>)
+      && __detail::__partially_ordered_with<_Tp, _Tp>
       && requires(const remove_reference_t<_Tp>& __a,
 		  const remove_reference_t<_Tp>& __b) {
 	{ __a <=> __b } -> __detail::__compares_as<_Cat>;
@@ -426,16 +425,15 @@  namespace std
 
   template<typename _Tp, typename _Up, typename _Cat = partial_ordering>
     concept three_way_comparable_with
-      = __detail::__weakly_eq_cmp_with<_Tp, _Up>
-      && (!convertible_to<_Cat, partial_ordering>
-	  || __detail::__partially_ordered_with<_Tp, _Up>)
-      && three_way_comparable<_Tp, _Cat>
+      = three_way_comparable<_Tp, _Cat>
       && three_way_comparable<_Up, _Cat>
       && common_reference_with<const remove_reference_t<_Tp>&,
 			       const remove_reference_t<_Up>&>
       && three_way_comparable<
 	  common_reference_t<const remove_reference_t<_Tp>&,
 			     const remove_reference_t<_Up>&>, _Cat>
+      && __detail::__weakly_eq_cmp_with<_Tp, _Up>
+      && __detail::__partially_ordered_with<_Tp, _Up>
       && requires(const remove_reference_t<_Tp>& __t,
 		  const remove_reference_t<_Up>& __u) {
 	{ __t <=> __u } -> __detail::__compares_as<_Cat>;

commit 0294dc5f4eec5a07d70fac48f75c498c3b1a339b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 19 21:40:03 2020 +0000

    libstdc++: Simplify std::totally_ordered (LWG 3331)
    
            * include/std/concepts (__detail::__partially_ordered_with): Move here
            from <compare>.
            (totally_ordered, totally_ordered_with): Use __partially_ordered_with
            to simplify definition (LWG 3331).
            * libsupc++/compare (__detail::__partially_ordered_with): Move to
            <concepts>.

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 3941bcbe7ba..1711a359256 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,12 @@ 
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+	* include/std/concepts (__detail::__partially_ordered_with): Move here
+	from <compare>.
+	(totally_ordered, totally_ordered_with): Use __partially_ordered_with
+	to simplify definition (LWG 3331).
+	* libsupc++/compare (__detail::__partially_ordered_with): Move to
+	<concepts>.
+
 	* include/std/concepts (totally_ordered_with): Remove redundant
 	requirement (LWG 3329).
 
diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts
index be125c636a1..ba232e953ec 100644
--- a/libstdc++-v3/include/std/concepts
+++ b/libstdc++-v3/include/std/concepts
@@ -297,16 +297,28 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 						__detail::__cref<_Up>>>
       && __detail::__weakly_eq_cmp_with<_Tp, _Up>;
 
+  namespace __detail
+  {
+    template<typename _Tp, typename _Up>
+      concept __partially_ordered_with
+	= requires(const remove_reference_t<_Tp>& __t,
+		   const remove_reference_t<_Up>& __u) {
+	  { __t <  __u } -> __boolean_testable;
+	  { __t >  __u } -> __boolean_testable;
+	  { __t <= __u } -> __boolean_testable;
+	  { __t >= __u } -> __boolean_testable;
+	  { __u <  __t } -> __boolean_testable;
+	  { __u >  __t } -> __boolean_testable;
+	  { __u <= __t } -> __boolean_testable;
+	  { __u >= __t } -> __boolean_testable;
+	};
+  } // namespace __detail
+
   // [concept.totallyordered], concept totally_ordered
   template<typename _Tp>
     concept totally_ordered
       = equality_comparable<_Tp>
-      && requires(__detail::__cref<_Tp> __a, __detail::__cref<_Tp> __b) {
-	{ __a <  __b } -> __detail::__boolean_testable;
-	{ __a >  __b } -> __detail::__boolean_testable;
-	{ __a <= __b } -> __detail::__boolean_testable;
-	{ __a >= __b } -> __detail::__boolean_testable;
-      };
+      && __detail::__partially_ordered_with<_Tp, _Tp>;
 
   template<typename _Tp, typename _Up>
     concept totally_ordered_with
@@ -314,16 +326,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       && equality_comparable_with<_Tp, _Up>
       && totally_ordered<common_reference_t<__detail::__cref<_Tp>,
 					    __detail::__cref<_Up>>>
-      && requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) {
-	{ __t <  __u } -> __detail::__boolean_testable;
-	{ __t >  __u } -> __detail::__boolean_testable;
-	{ __t <= __u } -> __detail::__boolean_testable;
-	{ __t >= __u } -> __detail::__boolean_testable;
-	{ __u <  __t } -> __detail::__boolean_testable;
-	{ __u >  __t } -> __detail::__boolean_testable;
-	{ __u <= __t } -> __detail::__boolean_testable;
-	{ __u >= __t } -> __detail::__boolean_testable;
-      };
+      && __detail::__partially_ordered_with<_Tp, _Up>;
 
   template<typename _Tp>
     concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index ba7db316486..a74ebc845bf 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -411,20 +411,6 @@  namespace std
     template<typename _Tp, typename _Cat>
       concept __compares_as
 	= same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
-
-    template<typename _Tp, typename _Up>
-      concept __partially_ordered_with
-	= requires(const remove_reference_t<_Tp>& __t,
-		   const remove_reference_t<_Up>& __u) {
-	  { __t <  __u } -> __boolean_testable;
-	  { __t >  __u } -> __boolean_testable;
-	  { __t <= __u } -> __boolean_testable;
-	  { __t >= __u } -> __boolean_testable;
-	  { __u <  __t } -> __boolean_testable;
-	  { __u >  __t } -> __boolean_testable;
-	  { __u <= __t } -> __boolean_testable;
-	  { __u >= __t } -> __boolean_testable;
-	};
   } // namespace __detail
 
   // [cmp.concept], concept three_way_comparable

commit 241ed965509ac931e9ae5f331d0294c1ee4ccd89
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 19 21:31:06 2020 +0000

    libstdc++: Simplify std::totally_ordered_with (LWG 3329)
    
            * include/std/concepts (totally_ordered_with): Remove redundant
            requirement (LWG 3329).

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 6e22536680f..3941bcbe7ba 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,8 @@ 
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+	* include/std/concepts (totally_ordered_with): Remove redundant
+	requirement (LWG 3329).
+
 	* include/std/ranges (__detail::__convertible_to_non_slicing): New
 	helper concept.
 	(__detail::__pair_like_convertible_to): Remove.
diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts
index f3db40b798f..be125c636a1 100644
--- a/libstdc++-v3/include/std/concepts
+++ b/libstdc++-v3/include/std/concepts
@@ -311,10 +311,9 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp, typename _Up>
     concept totally_ordered_with
       = totally_ordered<_Tp> && totally_ordered<_Up>
-      && common_reference_with<__detail::__cref<_Tp>, __detail::__cref<_Up>>
+      && equality_comparable_with<_Tp, _Up>
       && totally_ordered<common_reference_t<__detail::__cref<_Tp>,
 					    __detail::__cref<_Up>>>
-      && equality_comparable_with<_Tp, _Up>
       && requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) {
 	{ __t <  __u } -> __detail::__boolean_testable;
 	{ __t >  __u } -> __detail::__boolean_testable;