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

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


https://gcc.gnu.org/g:46f2ed78d53893087165dc28238a8bc81101b599

commit r13-9542-g46f2ed78d53893087165dc28238a8bc81101b599
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 ad7c54bb51c4..001f72edb789 100644
--- a/libstdc++-v3/include/bits/ranges_algobase.h
+++ b/libstdc++-v3/include/bits/ranges_algobase.h
@@ -202,16 +202,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>
@@ -271,14 +261,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;
 	    }
@@ -288,7 +278,7 @@ namespace ranges
 	{
 	  while (__first != __last)
 	    {
-	      ranges::__assign_one<_IsMove>(__first, __result);
+	      std::__assign_one<_IsMove>(__result, __first);
 	      ++__first;
 	      ++__result;
 	    }
@@ -400,7 +390,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};
 		}
 	    }
@@ -412,7 +402,7 @@ namespace ranges
 	    {
 	      --__tail;
 	      --__result;
-	      ranges::__assign_one<_IsMove>(__tail, __result);
+	      std::__assign_one<_IsMove>(__result, __tail);
 	    }
 	  return {std::move(__lasti), std::move(__result)};
 	}
@@ -425,7 +415,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