]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Reuse std::__assign_one in <bits/ranges_algobase.h>
authorJonathan Wakely <jwakely@redhat.com>
Mon, 14 Oct 2024 22:34:20 +0000 (23:34 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 16 Apr 2025 08:39:24 +0000 (09:39 +0100)
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)

libstdc++-v3/include/bits/ranges_algobase.h

index 4451fa2feba64b8723ba69eeb86cd26006e1b484..a578bdb6fc5f60cc183a07bb8b6d728742aa2813 100644 (file)
@@ -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)};
        }