[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos-adaptors)] Reduce amount of stuff copied from ranges_algo.h

Patrick Palka ppalka@gcc.gnu.org
Thu Feb 6 23:25:00 GMT 2020


https://gcc.gnu.org/g:b72088ca3babd9c68e15997942bf2ff7d4f8a059

commit b72088ca3babd9c68e15997942bf2ff7d4f8a059
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Feb 6 18:05:59 2020 -0500

    Reduce amount of stuff copied from ranges_algo.h

Diff:
---
 libstdc++-v3/include/std/ranges | 57 +++++++----------------------------------
 1 file changed, 9 insertions(+), 48 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 5f5786b..8a8fefb 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -1141,8 +1141,8 @@ namespace views
   template<viewable_range _Range>
     using all_view = decltype(views::all(declval<_Range>()));
 
-  // XXX: the following algos are copied verbatim from ranges_algo.h to avoid a
-  // circular dependency with that header.
+  // XXX: the following algos are copied from ranges_algo.h to avoid a circular
+  // dependency with that header.
   namespace __detail
   {
     template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
@@ -1157,16 +1157,6 @@ namespace views
 	return __first;
       }
 
-    template<input_range _Range, typename _Proj = identity,
-	     indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>>
-	       _Pred>
-      constexpr safe_iterator_t<_Range>
-      find_if(_Range&& __r, _Pred __pred, _Proj __proj = {})
-      {
-	return __detail::find_if(ranges::begin(__r), ranges::end(__r),
-				 std::move(__pred), std::move(__proj));
-      }
-
     template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
 	     typename _Proj = identity,
 	     indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
@@ -1179,16 +1169,6 @@ namespace views
 	return __first;
       }
 
-    template<input_range _Range, typename _Proj = identity,
-	     indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>>
-	       _Pred>
-      constexpr safe_iterator_t<_Range>
-      find_if_not(_Range&& __r, _Pred __pred, _Proj __proj = {})
-      {
-	return __detail::find_if_not(ranges::begin(__r), ranges::end(__r),
-				     std::move(__pred), std::move(__proj));
-      }
-
     template<typename _Tp, typename _Proj = identity,
 	     indirect_strict_weak_order<projected<const _Tp*, _Proj>>
 	       _Comp = ranges::less>
@@ -1203,35 +1183,12 @@ namespace views
 	  return __a;
       }
 
-    template<typename _Iter1, typename _Iter2>
-      struct mismatch_result
-      {
-	[[no_unique_address]] _Iter1 in1;
-	[[no_unique_address]] _Iter2 in2;
-
-	template<typename _IIter1, typename _IIter2>
-	  requires convertible_to<const _Iter1&, _IIter1>
-	    && convertible_to<const _Iter2&, _IIter2>
-	  operator mismatch_result<_IIter1, _IIter2>() const &
-	  {
-	    return {in1, in2};
-	  }
-
-	template<typename _IIter1, typename _IIter2>
-	  requires convertible_to<_Iter1, _IIter1>
-	    && convertible_to<_Iter2, _IIter2>
-	  operator mismatch_result<_IIter1, _IIter2>() &&
-	  {
-	    return {std::move(in1), std::move(in2)};
-	  }
-      };
-
     template<input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
 	     input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
 	     typename _Pred = ranges::equal_to,
 	     typename _Proj1 = identity, typename _Proj2 = identity>
       requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
-      constexpr mismatch_result<_Iter1, _Iter2>
+      constexpr pair<_Iter1, _Iter2>
       mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
 	       _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
       {
@@ -1435,7 +1392,9 @@ namespace views
       {
 	// XXX: we need to cache the result here as per [range.filter.view]
 	__glibcxx_assert(_M_pred.has_value());
-	return {*this, __detail::find_if(_M_base, std::ref(*_M_pred))};
+	return {*this, __detail::find_if(ranges::begin(_M_base),
+					 ranges::end(_M_base),
+					 std::ref(*_M_pred))};
       }
 
       constexpr auto
@@ -2150,7 +2109,9 @@ namespace views
       begin()
       {
 	// XXX: we need to cache the result here as per [range.drop.while.view]
-	return __detail::find_if_not(_M_base, cref(*_M_pred));
+	return __detail::find_if_not(ranges::begin(_M_base),
+				     ranges::end(_M_base),
+				     std::cref(*_M_pred));
       }
 
       constexpr auto



More information about the Libstdc++-cvs mailing list