[gcc r14-11624] libstdc++: Reuse std::__assign_one in <bits/ranges_algobase.h>

Jonathan Wakely redi@gcc.gnu.org
Wed Apr 16 09:02:09 GMT 2025


https://gcc.gnu.org/g:542c7e9b3f4a118cbe2f9fa59aeafb23aab31e0b

commit r14-11624-g542c7e9b3f4a118cbe2f9fa59aeafb23aab31e0b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Oct 14 23:34:20 2024 +0100

    libstdc++: Reuse std::__assign_one in <bits/ranges_algobase.h>
    
    Use std::__assign_one instead of ranges::__assign_one. Adjust the uses,
    because std::__assign_one has the arguments in the opposite order (the
    same order as an assignment expression).
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/ranges_algobase.h (ranges::__assign_one): Remove.
            (__copy_or_move, __copy_or_move_backward): Use std::__assign_one
            instead of ranges::__assign_one.
    
    Reviewed-by: Patrick Palka <ppalka@redhat.com>
    (cherry picked from commit d0a9ae1321f01c33b7ee377249cad30187061c0c)

Diff:
---
 libstdc++-v3/include/bits/ranges_algobase.h | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/include/bits/ranges_algobase.h b/libstdc++-v3/include/bits/ranges_algobase.h
index 4451fa2feba6..a578bdb6fc5f 100644
--- a/libstdc++-v3/include/bits/ranges_algobase.h
+++ b/libstdc++-v3/include/bits/ranges_algobase.h
@@ -209,16 +209,6 @@ namespace ranges
 			      copy_backward_result<_Iter, _Out>>
     __copy_or_move_backward(_Iter __first, _Sent __last, _Out __result);
 
-  template<bool _IsMove, typename _Iter, typename _Out>
-    constexpr void
-    __assign_one(_Iter& __iter, _Out& __result)
-    {
-      if constexpr (_IsMove)
-	  *__result = std::move(*__iter);
-      else
-	  *__result = *__iter;
-    }
-
   template<bool _IsMove,
 	   input_iterator _Iter, sentinel_for<_Iter> _Sent,
 	   weakly_incrementable _Out>
@@ -278,14 +268,14 @@ namespace ranges
 		    __builtin_memmove(__result, __first,
 				      sizeof(_ValueTypeI) * __num);
 		  else if (__num == 1)
-		    ranges::__assign_one<_IsMove>(__first, __result);
+		    std::__assign_one<_IsMove>(__result, __first);
 		  return {__first + __num, __result + __num};
 		}
 	    }
 
 	  for (auto __n = __last - __first; __n > 0; --__n)
 	    {
-	      ranges::__assign_one<_IsMove>(__first, __result);
+	      std::__assign_one<_IsMove>(__result, __first);
 	      ++__first;
 	      ++__result;
 	    }
@@ -295,7 +285,7 @@ namespace ranges
 	{
 	  while (__first != __last)
 	    {
-	      ranges::__assign_one<_IsMove>(__first, __result);
+	      std::__assign_one<_IsMove>(__result, __first);
 	      ++__first;
 	      ++__result;
 	    }
@@ -407,7 +397,7 @@ namespace ranges
 		    __builtin_memmove(__result, __first,
 				      sizeof(_ValueTypeI) * __num);
 		  else if (__num == 1)
-		    ranges::__assign_one<_IsMove>(__first, __result);
+		    std::__assign_one<_IsMove>(__result, __first);
 		  return {__first + __num, __result};
 		}
 	    }
@@ -419,7 +409,7 @@ namespace ranges
 	    {
 	      --__tail;
 	      --__result;
-	      ranges::__assign_one<_IsMove>(__tail, __result);
+	      std::__assign_one<_IsMove>(__result, __tail);
 	    }
 	  return {std::move(__lasti), std::move(__result)};
 	}
@@ -432,7 +422,7 @@ namespace ranges
 	    {
 	      --__tail;
 	      --__result;
-	      ranges::__assign_one<_IsMove>(__tail, __result);
+	      std::__assign_one<_IsMove>(__result, __tail);
 	    }
 	  return {std::move(__lasti), std::move(__result)};
 	}


More information about the Libstdc++-cvs mailing list