]> 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>
Fri, 18 Oct 2024 13:49:35 +0000 (14:49 +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>
libstdc++-v3/include/bits/ranges_algobase.h

index 0345ea850a4e5db173016b00526609f7e6b948f0..df4e770e7a6509c5f847cc7e3d20833bad2c6671 100644 (file)
@@ -225,16 +225,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>
@@ -294,14 +284,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;
            }
@@ -311,7 +301,7 @@ namespace ranges
        {
          while (__first != __last)
            {
-             ranges::__assign_one<_IsMove>(__first, __result);
+             std::__assign_one<_IsMove>(__result, __first);
              ++__first;
              ++__result;
            }
@@ -423,7 +413,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};
                }
            }
@@ -435,7 +425,7 @@ namespace ranges
            {
              --__tail;
              --__result;
-             ranges::__assign_one<_IsMove>(__tail, __result);
+             std::__assign_one<_IsMove>(__result, __tail);
            }
          return {std::move(__lasti), std::move(__result)};
        }
@@ -448,7 +438,7 @@ namespace ranges
            {
              --__tail;
              --__result;
-             ranges::__assign_one<_IsMove>(__tail, __result);
+             std::__assign_one<_IsMove>(__result, __tail);
            }
          return {std::move(__lasti), std::move(__result)};
        }