From b4d424c686075c9605f0f5107d51eb1e64abb530 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 12 Nov 2024 16:47:02 +0100 Subject: [PATCH] [libc++] Remove _AlgPolicy from std::copy --- libcxx/include/__algorithm/copy.h | 15 ++++++--------- libcxx/include/__algorithm/copy_move_common.h | 1 - libcxx/include/__algorithm/ranges_copy.h | 5 ++--- libcxx/include/__algorithm/ranges_copy_n.h | 2 +- .../include/__algorithm/ranges_set_difference.h | 5 ++--- .../__algorithm/ranges_set_symmetric_difference.h | 5 ++--- libcxx/include/__algorithm/ranges_set_union.h | 5 ++--- libcxx/include/__algorithm/set_difference.h | 10 ++++------ .../__algorithm/set_symmetric_difference.h | 9 ++++----- libcxx/include/__algorithm/set_union.h | 9 ++++----- libcxx/include/__vector/vector.h | 4 ++-- libcxx/include/__vector/vector_bool.h | 4 ++-- 12 files changed, 31 insertions(+), 43 deletions(-) diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h index 7ae47514d6d27..4f30b2050abba 100644 --- a/libcxx/include/__algorithm/copy.h +++ b/libcxx/include/__algorithm/copy.h @@ -11,7 +11,6 @@ #include <__algorithm/copy_move_common.h> #include <__algorithm/for_each_segment.h> -#include <__algorithm/iterator_operations.h> #include <__algorithm/min.h> #include <__config> #include <__iterator/iterator_traits.h> @@ -30,10 +29,9 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template +template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); -template struct __copy_impl { template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> @@ -58,7 +56,7 @@ struct __copy_impl { _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) { - __result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second; + __result_ = std::__copy(__lfirst, __llast, std::move(__result_)).second; } }; @@ -87,7 +85,7 @@ struct __copy_impl { while (true) { auto __local_last = _Traits::__end(__segment_iterator); auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); - auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first); + auto __iters = std::__copy(__first, __first + __size, __local_first); __first = std::move(__iters.first); if (__first == __last) @@ -105,17 +103,16 @@ struct __copy_impl { } }; -template +template pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __copy(_InIter __first, _Sent __last, _OutIter __result) { - return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >( - std::move(__first), std::move(__last), std::move(__result)); + return std::__copy_move_unwrap_iters<__copy_impl>(std::move(__first), std::move(__last), std::move(__result)); } template inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second; + return std::__copy(__first, __last, __result).second; } _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__algorithm/copy_move_common.h b/libcxx/include/__algorithm/copy_move_common.h index d76bf4903aaa9..7471012c01d96 100644 --- a/libcxx/include/__algorithm/copy_move_common.h +++ b/libcxx/include/__algorithm/copy_move_common.h @@ -9,7 +9,6 @@ #ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H #define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H -#include <__algorithm/iterator_operations.h> #include <__algorithm/unwrap_iter.h> #include <__algorithm/unwrap_range.h> #include <__config> diff --git a/libcxx/include/__algorithm/ranges_copy.h b/libcxx/include/__algorithm/ranges_copy.h index 05b61c0d5d4ab..a69af9b2bffc3 100644 --- a/libcxx/include/__algorithm/ranges_copy.h +++ b/libcxx/include/__algorithm/ranges_copy.h @@ -11,7 +11,6 @@ #include <__algorithm/copy.h> #include <__algorithm/in_out_result.h> -#include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> #include <__iterator/concepts.h> @@ -42,7 +41,7 @@ struct __copy { requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { - auto __ret = std::__copy<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); + auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result)); return {std::move(__ret.first), std::move(__ret.second)}; } @@ -50,7 +49,7 @@ struct __copy { requires indirectly_copyable, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr copy_result, _OutIter> operator()(_Range&& __r, _OutIter __result) const { - auto __ret = std::__copy<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result)); + auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result)); return {std::move(__ret.first), std::move(__ret.second)}; } }; diff --git a/libcxx/include/__algorithm/ranges_copy_n.h b/libcxx/include/__algorithm/ranges_copy_n.h index 79ce1580490d4..1fbc61674e2dd 100644 --- a/libcxx/include/__algorithm/ranges_copy_n.h +++ b/libcxx/include/__algorithm/ranges_copy_n.h @@ -54,7 +54,7 @@ struct __copy_n { template _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) { - auto __ret = std::__copy<_RangeAlgPolicy>(__first, __first + __n, __result); + auto __ret = std::__copy(__first, __first + __n, __result); return {__ret.first, __ret.second}; } diff --git a/libcxx/include/__algorithm/ranges_set_difference.h b/libcxx/include/__algorithm/ranges_set_difference.h index aa36e358ef6f9..1c83c7bdd5a33 100644 --- a/libcxx/include/__algorithm/ranges_set_difference.h +++ b/libcxx/include/__algorithm/ranges_set_difference.h @@ -10,7 +10,6 @@ #define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H #include <__algorithm/in_out_result.h> -#include <__algorithm/iterator_operations.h> #include <__algorithm/make_projected.h> #include <__algorithm/set_difference.h> #include <__config> @@ -61,7 +60,7 @@ struct __set_difference { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - auto __ret = std::__set_difference<_RangeAlgPolicy>( + auto __ret = std::__set_difference( __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2)); return {std::move(__ret.first), std::move(__ret.second)}; } @@ -80,7 +79,7 @@ struct __set_difference { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - auto __ret = std::__set_difference<_RangeAlgPolicy>( + auto __ret = std::__set_difference( ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), diff --git a/libcxx/include/__algorithm/ranges_set_symmetric_difference.h b/libcxx/include/__algorithm/ranges_set_symmetric_difference.h index e3b73c3eb1cf2..c0a814043192c 100644 --- a/libcxx/include/__algorithm/ranges_set_symmetric_difference.h +++ b/libcxx/include/__algorithm/ranges_set_symmetric_difference.h @@ -10,7 +10,6 @@ #define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H #include <__algorithm/in_in_out_result.h> -#include <__algorithm/iterator_operations.h> #include <__algorithm/make_projected.h> #include <__algorithm/set_symmetric_difference.h> #include <__config> @@ -59,7 +58,7 @@ struct __set_symmetric_difference { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>( + auto __ret = std::__set_symmetric_difference( std::move(__first1), std::move(__last1), std::move(__first2), @@ -85,7 +84,7 @@ struct __set_symmetric_difference { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>( + auto __ret = std::__set_symmetric_difference( ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), diff --git a/libcxx/include/__algorithm/ranges_set_union.h b/libcxx/include/__algorithm/ranges_set_union.h index f2e3ddb89d7b3..039ffb5932f3a 100644 --- a/libcxx/include/__algorithm/ranges_set_union.h +++ b/libcxx/include/__algorithm/ranges_set_union.h @@ -10,7 +10,6 @@ #define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H #include <__algorithm/in_in_out_result.h> -#include <__algorithm/iterator_operations.h> #include <__algorithm/make_projected.h> #include <__algorithm/set_union.h> #include <__config> @@ -62,7 +61,7 @@ struct __set_union { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - auto __ret = std::__set_union<_RangeAlgPolicy>( + auto __ret = std::__set_union( std::move(__first1), std::move(__last1), std::move(__first2), @@ -86,7 +85,7 @@ struct __set_union { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - auto __ret = std::__set_union<_RangeAlgPolicy>( + auto __ret = std::__set_union( ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), diff --git a/libcxx/include/__algorithm/set_difference.h b/libcxx/include/__algorithm/set_difference.h index 6230b831aeda2..0cd1bc45d64f7 100644 --- a/libcxx/include/__algorithm/set_difference.h +++ b/libcxx/include/__algorithm/set_difference.h @@ -12,7 +12,6 @@ #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> #include <__iterator/iterator_traits.h> @@ -29,7 +28,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template +template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> > __set_difference( _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) { @@ -45,7 +44,7 @@ __set_difference( ++__first2; } } - return std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result)); + return std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); } template @@ -56,8 +55,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { - return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >( - __first1, __last1, __first2, __last2, __result, __comp) + return std::__set_difference<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp) .second; } @@ -68,7 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { - return std::__set_difference<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __result, __less<>()).second; + return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).second; } _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__algorithm/set_symmetric_difference.h b/libcxx/include/__algorithm/set_symmetric_difference.h index db36665a61365..91ea4067c0d0f 100644 --- a/libcxx/include/__algorithm/set_symmetric_difference.h +++ b/libcxx/include/__algorithm/set_symmetric_difference.h @@ -12,7 +12,6 @@ #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__algorithm/iterator_operations.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__utility/move.h> @@ -39,13 +38,13 @@ struct __set_symmetric_difference_result { : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} }; -template +template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter> __set_symmetric_difference( _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { while (__first1 != __last1) { if (__first2 == __last2) { - auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result)); + auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>( std::move(__ret1.first), std::move(__first2), std::move((__ret1.second))); } @@ -63,7 +62,7 @@ __set_symmetric_difference( ++__first2; } } - auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result)); + auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result)); return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>( std::move(__first1), std::move(__ret2.first), std::move((__ret2.second))); } @@ -76,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetri _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { - return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >( + return std::__set_symmetric_difference<__comp_ref_type<_Compare> >( std::move(__first1), std::move(__last1), std::move(__first2), diff --git a/libcxx/include/__algorithm/set_union.h b/libcxx/include/__algorithm/set_union.h index a79c50fd3cf2f..393dddce4302a 100644 --- a/libcxx/include/__algorithm/set_union.h +++ b/libcxx/include/__algorithm/set_union.h @@ -12,7 +12,6 @@ #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__algorithm/iterator_operations.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__utility/move.h> @@ -39,12 +38,12 @@ struct __set_union_result { : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} }; -template +template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union( _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { for (; __first1 != __last1; ++__result) { if (__first2 == __last2) { - auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result)); + auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); return __set_union_result<_InIter1, _InIter2, _OutIter>( std::move(__ret1.first), std::move(__first2), std::move((__ret1.second))); } @@ -59,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, ++__first1; } } - auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result)); + auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result)); return __set_union_result<_InIter1, _InIter2, _OutIter>( std::move(__first1), std::move(__ret2.first), std::move((__ret2.second))); } @@ -72,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union( _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { - return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >( + return std::__set_union<__comp_ref_type<_Compare> >( std::move(__first1), std::move(__last1), std::move(__first2), diff --git a/libcxx/include/__vector/vector.h b/libcxx/include/__vector/vector.h index 6db202efb279b..d6bf58d02c414 100644 --- a/libcxx/include/__vector/vector.h +++ b/libcxx/include/__vector/vector.h @@ -11,7 +11,6 @@ #include <__algorithm/copy.h> #include <__algorithm/fill_n.h> -#include <__algorithm/iterator_operations.h> #include <__algorithm/max.h> #include <__algorithm/min.h> #include <__algorithm/move.h> @@ -22,6 +21,7 @@ #include <__debug_utils/sanitizers.h> #include <__format/enable_insertable.h> #include <__fwd/vector.h> +#include <__iterator/advance.h> #include <__iterator/bounded_iter.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> @@ -1033,7 +1033,7 @@ vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel std::copy(__first, __mid, this->__begin_); __construct_at_end(__mid, __last, __new_size - size()); } else { - pointer __m = std::__copy<_ClassicAlgPolicy>(__first, __last, this->__begin_).second; + pointer __m = std::__copy(__first, __last, this->__begin_).second; this->__destruct_at_end(__m); } } else { diff --git a/libcxx/include/__vector/vector_bool.h b/libcxx/include/__vector/vector_bool.h index 462095fd07acf..bc6a61ad3215f 100644 --- a/libcxx/include/__vector/vector_bool.h +++ b/libcxx/include/__vector/vector_bool.h @@ -574,7 +574,7 @@ vector::__construct_at_end(_InputIterator __first, _Sentinel _ else this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); } - std::__copy<_ClassicAlgPolicy>(__first, __last, __make_iter(__old_size)); + std::__copy(__first, __last, __make_iter(__old_size)); } template @@ -1002,7 +1002,7 @@ vector::__insert_with_size( std::copy_backward(__position, cend(), __v.end()); swap(__v); } - std::__copy<_ClassicAlgPolicy>(__first, __last, __r); + std::__copy(__first, __last, __r); return __r; }