|
27 | 27 | // - if all values of a radix are the same, we do not sort that radix, and just move items to the buffer; |
28 | 28 | // - if two consecutive radices satisfies condition above, we do nothing for these two radices. |
29 | 29 |
|
30 | | -#include <__algorithm/copy.h> |
31 | 30 | #include <__algorithm/for_each.h> |
| 31 | +#include <__algorithm/move.h> |
32 | 32 | #include <__bit/countl.h> |
33 | 33 | #include <__config> |
34 | 34 | #include <__functional/identity.h> |
@@ -65,16 +65,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
65 | 65 |
|
66 | 66 | #if _LIBCPP_STD_VER >= 14 |
67 | 67 |
|
68 | | -template <class _Iterator, enable_if_t<is_move_assignable<__iter_value_type<_Iterator>>::value, int> = 0> |
69 | | -_LIBCPP_HIDE_FROM_ABI constexpr move_iterator<_Iterator> __move_assign_please(_Iterator __i) { |
70 | | - return std::make_move_iterator(std::move(__i)); |
71 | | -} |
72 | | - |
73 | | -template <class _Iterator, enable_if_t<!is_move_assignable<__iter_value_type<_Iterator>>::value, int> = 0> |
74 | | -_LIBCPP_HIDE_FROM_ABI constexpr _Iterator __move_assign_please(_Iterator __i) { |
75 | | - return __i; |
76 | | -} |
77 | | - |
78 | 68 | template <class _UnsignedInteger> |
79 | 69 | _LIBCPP_HIDE_FROM_ABI constexpr _UnsignedInteger __intlog2(_UnsignedInteger __n) { |
80 | 70 | static_assert(is_unsigned<_UnsignedInteger>::value, "Must be unsigned integral"); |
@@ -153,7 +143,7 @@ __dispose(_ForwardIterator __first, |
153 | 143 | _RandomAccessIterator2 __counters) { |
154 | 144 | std::for_each(__first, __last, [&__result, &__counters, &__map](auto&& __preimage) { |
155 | 145 | auto __index = __counters[__map(__preimage)]++; |
156 | | - __result[__index] = std::forward<decltype(__preimage)>(__preimage); |
| 146 | + __result[__index] = std::move(__preimage); |
157 | 147 | }); |
158 | 148 | } |
159 | 149 |
|
@@ -217,7 +207,7 @@ _LIBCPP_HIDE_FROM_ABI void __dispose_backward( |
217 | 207 | std::make_reverse_iterator(__first), |
218 | 208 | [&__result, &__counters, &__map](auto&& __preimage) { |
219 | 209 | auto __index = --__counters[__map(__preimage)]; |
220 | | - __result[__index] = std::forward<decltype(__preimage)>(__preimage); |
| 210 | + __result[__index] = std::move(__preimage); |
221 | 211 | }); |
222 | 212 | } |
223 | 213 |
|
@@ -247,13 +237,11 @@ _LIBCPP_HIDE_FROM_ABI void __radix_sort_impl( |
247 | 237 | _RandomAccessIterator2 __buffer, |
248 | 238 | _Map __map, |
249 | 239 | _Radix __radix) { |
250 | | - auto __buffer_end = std::__counting_sort_impl( |
251 | | - std::__move_assign_please(__first), |
252 | | - std::__move_assign_please(__last), |
253 | | - __buffer, |
254 | | - [&__map, &__radix](const auto& value) { return __radix(__map(value)); }); |
| 240 | + auto __buffer_end = std::__counting_sort_impl(__first, __last, __buffer, [&__map, &__radix](const auto& value) { |
| 241 | + return __radix(__map(value)); |
| 242 | + }); |
255 | 243 |
|
256 | | - std::copy(std::__move_assign_please(__buffer), std::__move_assign_please(__buffer_end), __first); |
| 244 | + std::move(__buffer, __buffer_end, __first); |
257 | 245 | } |
258 | 246 |
|
259 | 247 | template < |
@@ -287,31 +275,21 @@ _LIBCPP_HIDE_FROM_ABI void __radix_sort_impl( |
287 | 275 | } |
288 | 276 |
|
289 | 277 | if (__n0th_is_single) { |
290 | | - std::copy(std::__move_assign_please(__first), std::__move_assign_please(__last), __buffer_begin); |
| 278 | + std::move(__first, __last, __buffer_begin); |
291 | 279 | } else { |
292 | 280 | auto __n0th = [__radix_number, &__map, &__radix](const auto& __v) { |
293 | 281 | return std::__nth_radix(__radix_number, __radix, __map(__v)); |
294 | 282 | }; |
295 | | - std::__dispose_backward( |
296 | | - std::__move_assign_please(__first), |
297 | | - std::__move_assign_please(__last), |
298 | | - __buffer_begin, |
299 | | - __n0th, |
300 | | - __counters[__radix_number]); |
| 283 | + std::__dispose_backward(__first, __last, __buffer_begin, __n0th, __counters[__radix_number]); |
301 | 284 | } |
302 | 285 |
|
303 | 286 | if (__n1th_is_single) { |
304 | | - std::copy(std::__move_assign_please(__buffer_begin), std::__move_assign_please(__buffer_end), __first); |
| 287 | + std::move(__buffer_begin, __buffer_end, __first); |
305 | 288 | } else { |
306 | 289 | auto __n1th = [__radix_number, &__map, &__radix](const auto& __v) { |
307 | 290 | return std::__nth_radix(__radix_number + 1, __radix, __map(__v)); |
308 | 291 | }; |
309 | | - std::__dispose_backward( |
310 | | - std::__move_assign_please(__buffer_begin), |
311 | | - std::__move_assign_please(__buffer_end), |
312 | | - __first, |
313 | | - __n1th, |
314 | | - __counters[__radix_number + 1]); |
| 292 | + std::__dispose_backward(__buffer_begin, __buffer_end, __first, __n1th, __counters[__radix_number + 1]); |
315 | 293 | } |
316 | 294 | } |
317 | 295 | } |
|
0 commit comments