Skip to content

Commit a204252

Browse files
authored
[libc++] Remove _AlgPolicy from std::copy and algorithms using std::copy (#115887)
`std::copy` doesn't use the `_AlgPolicy` for anything other than calling itself with it, so we can just remove the argument. This also removes the need in a few other algorithms which had an `_AlgPolicy` argument only to call `copy`.
1 parent 8da61a3 commit a204252

12 files changed

+31
-43
lines changed

libcxx/include/__algorithm/copy.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <__algorithm/copy_move_common.h>
1313
#include <__algorithm/for_each_segment.h>
14-
#include <__algorithm/iterator_operations.h>
1514
#include <__algorithm/min.h>
1615
#include <__config>
1716
#include <__iterator/iterator_traits.h>
@@ -30,10 +29,9 @@ _LIBCPP_PUSH_MACROS
3029

3130
_LIBCPP_BEGIN_NAMESPACE_STD
3231

33-
template <class, class _InIter, class _Sent, class _OutIter>
32+
template <class _InIter, class _Sent, class _OutIter>
3433
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
3534

36-
template <class _AlgPolicy>
3735
struct __copy_impl {
3836
template <class _InIter, class _Sent, class _OutIter>
3937
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
@@ -58,7 +56,7 @@ struct __copy_impl {
5856

5957
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
6058
operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
61-
__result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;
59+
__result_ = std::__copy(__lfirst, __llast, std::move(__result_)).second;
6260
}
6361
};
6462

@@ -87,7 +85,7 @@ struct __copy_impl {
8785
while (true) {
8886
auto __local_last = _Traits::__end(__segment_iterator);
8987
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
90-
auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
88+
auto __iters = std::__copy(__first, __first + __size, __local_first);
9189
__first = std::move(__iters.first);
9290

9391
if (__first == __last)
@@ -105,17 +103,16 @@ struct __copy_impl {
105103
}
106104
};
107105

108-
template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
106+
template <class _InIter, class _Sent, class _OutIter>
109107
pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
110108
__copy(_InIter __first, _Sent __last, _OutIter __result) {
111-
return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >(
112-
std::move(__first), std::move(__last), std::move(__result));
109+
return std::__copy_move_unwrap_iters<__copy_impl>(std::move(__first), std::move(__last), std::move(__result));
113110
}
114111

115112
template <class _InputIterator, class _OutputIterator>
116113
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
117114
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
118-
return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
115+
return std::__copy(__first, __last, __result).second;
119116
}
120117

121118
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/copy_move_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1010
#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1111

12-
#include <__algorithm/iterator_operations.h>
1312
#include <__algorithm/unwrap_iter.h>
1413
#include <__algorithm/unwrap_range.h>
1514
#include <__config>

libcxx/include/__algorithm/ranges_copy.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <__algorithm/copy.h>
1313
#include <__algorithm/in_out_result.h>
14-
#include <__algorithm/iterator_operations.h>
1514
#include <__config>
1615
#include <__functional/identity.h>
1716
#include <__iterator/concepts.h>
@@ -42,15 +41,15 @@ struct __copy {
4241
requires indirectly_copyable<_InIter, _OutIter>
4342
_LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter>
4443
operator()(_InIter __first, _Sent __last, _OutIter __result) const {
45-
auto __ret = std::__copy<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
44+
auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
4645
return {std::move(__ret.first), std::move(__ret.second)};
4746
}
4847

4948
template <input_range _Range, weakly_incrementable _OutIter>
5049
requires indirectly_copyable<iterator_t<_Range>, _OutIter>
5150
_LIBCPP_HIDE_FROM_ABI constexpr copy_result<borrowed_iterator_t<_Range>, _OutIter>
5251
operator()(_Range&& __r, _OutIter __result) const {
53-
auto __ret = std::__copy<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
52+
auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
5453
return {std::move(__ret.first), std::move(__ret.second)};
5554
}
5655
};

libcxx/include/__algorithm/ranges_copy_n.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct __copy_n {
5454
template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
5555
_LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter>
5656
__go(_InIter __first, _DiffType __n, _OutIter __result) {
57-
auto __ret = std::__copy<_RangeAlgPolicy>(__first, __first + __n, __result);
57+
auto __ret = std::__copy(__first, __first + __n, __result);
5858
return {__ret.first, __ret.second};
5959
}
6060

libcxx/include/__algorithm/ranges_set_difference.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
1111

1212
#include <__algorithm/in_out_result.h>
13-
#include <__algorithm/iterator_operations.h>
1413
#include <__algorithm/make_projected.h>
1514
#include <__algorithm/set_difference.h>
1615
#include <__config>
@@ -61,7 +60,7 @@ struct __set_difference {
6160
_Comp __comp = {},
6261
_Proj1 __proj1 = {},
6362
_Proj2 __proj2 = {}) const {
64-
auto __ret = std::__set_difference<_RangeAlgPolicy>(
63+
auto __ret = std::__set_difference(
6564
__first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
6665
return {std::move(__ret.first), std::move(__ret.second)};
6766
}
@@ -80,7 +79,7 @@ struct __set_difference {
8079
_Comp __comp = {},
8180
_Proj1 __proj1 = {},
8281
_Proj2 __proj2 = {}) const {
83-
auto __ret = std::__set_difference<_RangeAlgPolicy>(
82+
auto __ret = std::__set_difference(
8483
ranges::begin(__range1),
8584
ranges::end(__range1),
8685
ranges::begin(__range2),

libcxx/include/__algorithm/ranges_set_symmetric_difference.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
1111

1212
#include <__algorithm/in_in_out_result.h>
13-
#include <__algorithm/iterator_operations.h>
1413
#include <__algorithm/make_projected.h>
1514
#include <__algorithm/set_symmetric_difference.h>
1615
#include <__config>
@@ -59,7 +58,7 @@ struct __set_symmetric_difference {
5958
_Comp __comp = {},
6059
_Proj1 __proj1 = {},
6160
_Proj2 __proj2 = {}) const {
62-
auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
61+
auto __ret = std::__set_symmetric_difference(
6362
std::move(__first1),
6463
std::move(__last1),
6564
std::move(__first2),
@@ -85,7 +84,7 @@ struct __set_symmetric_difference {
8584
_Comp __comp = {},
8685
_Proj1 __proj1 = {},
8786
_Proj2 __proj2 = {}) const {
88-
auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
87+
auto __ret = std::__set_symmetric_difference(
8988
ranges::begin(__range1),
9089
ranges::end(__range1),
9190
ranges::begin(__range2),

libcxx/include/__algorithm/ranges_set_union.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
1111

1212
#include <__algorithm/in_in_out_result.h>
13-
#include <__algorithm/iterator_operations.h>
1413
#include <__algorithm/make_projected.h>
1514
#include <__algorithm/set_union.h>
1615
#include <__config>
@@ -62,7 +61,7 @@ struct __set_union {
6261
_Comp __comp = {},
6362
_Proj1 __proj1 = {},
6463
_Proj2 __proj2 = {}) const {
65-
auto __ret = std::__set_union<_RangeAlgPolicy>(
64+
auto __ret = std::__set_union(
6665
std::move(__first1),
6766
std::move(__last1),
6867
std::move(__first2),
@@ -86,7 +85,7 @@ struct __set_union {
8685
_Comp __comp = {},
8786
_Proj1 __proj1 = {},
8887
_Proj2 __proj2 = {}) const {
89-
auto __ret = std::__set_union<_RangeAlgPolicy>(
88+
auto __ret = std::__set_union(
9089
ranges::begin(__range1),
9190
ranges::end(__range1),
9291
ranges::begin(__range2),

libcxx/include/__algorithm/set_difference.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <__algorithm/comp.h>
1313
#include <__algorithm/comp_ref_type.h>
1414
#include <__algorithm/copy.h>
15-
#include <__algorithm/iterator_operations.h>
1615
#include <__config>
1716
#include <__functional/identity.h>
1817
#include <__iterator/iterator_traits.h>
@@ -29,7 +28,7 @@ _LIBCPP_PUSH_MACROS
2928

3029
_LIBCPP_BEGIN_NAMESPACE_STD
3130

32-
template <class _AlgPolicy, class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
31+
template <class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
3332
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
3433
__set_difference(
3534
_InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
@@ -45,7 +44,7 @@ __set_difference(
4544
++__first2;
4645
}
4746
}
48-
return std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
47+
return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
4948
}
5049

5150
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
@@ -56,8 +55,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d
5655
_InputIterator2 __last2,
5756
_OutputIterator __result,
5857
_Compare __comp) {
59-
return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
60-
__first1, __last1, __first2, __last2, __result, __comp)
58+
return std::__set_difference<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp)
6159
.second;
6260
}
6361

@@ -68,7 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d
6866
_InputIterator2 __first2,
6967
_InputIterator2 __last2,
7068
_OutputIterator __result) {
71-
return std::__set_difference<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __result, __less<>()).second;
69+
return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).second;
7270
}
7371

7472
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/set_symmetric_difference.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <__algorithm/comp.h>
1313
#include <__algorithm/comp_ref_type.h>
1414
#include <__algorithm/copy.h>
15-
#include <__algorithm/iterator_operations.h>
1615
#include <__config>
1716
#include <__iterator/iterator_traits.h>
1817
#include <__utility/move.h>
@@ -39,13 +38,13 @@ struct __set_symmetric_difference_result {
3938
: __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
4039
};
4140

42-
template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
41+
template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
4342
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
4443
__set_symmetric_difference(
4544
_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
4645
while (__first1 != __last1) {
4746
if (__first2 == __last2) {
48-
auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
47+
auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
4948
return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
5049
std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
5150
}
@@ -63,7 +62,7 @@ __set_symmetric_difference(
6362
++__first2;
6463
}
6564
}
66-
auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));
65+
auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result));
6766
return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
6867
std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
6968
}
@@ -76,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetri
7675
_InputIterator2 __last2,
7776
_OutputIterator __result,
7877
_Compare __comp) {
79-
return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
78+
return std::__set_symmetric_difference<__comp_ref_type<_Compare> >(
8079
std::move(__first1),
8180
std::move(__last1),
8281
std::move(__first2),

libcxx/include/__algorithm/set_union.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <__algorithm/comp.h>
1313
#include <__algorithm/comp_ref_type.h>
1414
#include <__algorithm/copy.h>
15-
#include <__algorithm/iterator_operations.h>
1615
#include <__config>
1716
#include <__iterator/iterator_traits.h>
1817
#include <__utility/move.h>
@@ -39,12 +38,12 @@ struct __set_union_result {
3938
: __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
4039
};
4140

42-
template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
41+
template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
4342
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
4443
_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
4544
for (; __first1 != __last1; ++__result) {
4645
if (__first2 == __last2) {
47-
auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
46+
auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
4847
return __set_union_result<_InIter1, _InIter2, _OutIter>(
4948
std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
5049
}
@@ -59,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1,
5958
++__first1;
6059
}
6160
}
62-
auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));
61+
auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result));
6362
return __set_union_result<_InIter1, _InIter2, _OutIter>(
6463
std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
6564
}
@@ -72,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union(
7271
_InputIterator2 __last2,
7372
_OutputIterator __result,
7473
_Compare __comp) {
75-
return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
74+
return std::__set_union<__comp_ref_type<_Compare> >(
7675
std::move(__first1),
7776
std::move(__last1),
7877
std::move(__first2),

0 commit comments

Comments
 (0)