Skip to content

Commit e5227d6

Browse files
committed
Add support for move-only iterators to lexicographical_compare_3way and equal
1 parent af9771c commit e5227d6

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

source/containers/algorithms/compare.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ export constexpr auto lexicographical_compare_3way(range auto && range1, range a
3838

3939

4040
export template<iterator InputIterator1, iterator InputIterator2>
41-
constexpr auto lexicographical_compare_3way(InputIterator1 const first1, sentinel_for<InputIterator1> auto const last1, InputIterator2 const first2, sentinel_for<InputIterator2> auto const last2) {
42-
return ::containers::lexicographical_compare_3way(first1, last1, first2, last2, std::compare_three_way());
41+
constexpr auto lexicographical_compare_3way(InputIterator1 first1, sentinel_for<InputIterator1> auto last1, InputIterator2 first2, sentinel_for<InputIterator2> auto last2) {
42+
return ::containers::lexicographical_compare_3way(
43+
std::move(first1),
44+
std::move(last1),
45+
std::move(first2),
46+
std::move(last2),
47+
std::compare_three_way()
48+
);
4349
}
4450

4551
export constexpr auto lexicographical_compare_3way(range auto && range1, range auto && range2) {
@@ -58,8 +64,13 @@ constexpr auto lexicographical_compare_3way(InputIterator1 first1, sentinel_for<
5864
}
5965

6066
export template<iterator InputIterator1>
61-
constexpr auto lexicographical_compare_3way(InputIterator1 const first1, sentinel_for<InputIterator1> auto const last1, iterator auto const first2) {
62-
return ::containers::lexicographical_compare_3way(first1, last1, first2, std::compare_three_way());
67+
constexpr auto lexicographical_compare_3way(InputIterator1 first1, sentinel_for<InputIterator1> auto last1, iterator auto first2) {
68+
return ::containers::lexicographical_compare_3way(
69+
std::move(first1),
70+
std::move(last1),
71+
std::move(first2),
72+
std::compare_three_way()
73+
);
6374
}
6475

6576

@@ -102,8 +113,14 @@ constexpr auto equal(InputIterator1 first1, sentinel_for<InputIterator1> auto co
102113

103114

104115
export template<iterator InputIterator1, iterator InputIterator2>
105-
constexpr auto equal(InputIterator1 const first1, sentinel_for<InputIterator1> auto const last1, InputIterator2 const first2, sentinel_for<InputIterator2> auto const last2) {
106-
return ::containers::equal(first1, last1, first2, last2, bounded::equal_to());
116+
constexpr auto equal(InputIterator1 first1, sentinel_for<InputIterator1> auto last1, InputIterator2 first2, sentinel_for<InputIterator2> auto last2) {
117+
return ::containers::equal(
118+
std::move(first1),
119+
std::move(last1),
120+
std::move(first2),
121+
std::move(last2),
122+
bounded::equal_to()
123+
);
107124
}
108125

109126
export template<iterator InputIterator1, iterator InputIterator2>
@@ -117,8 +134,13 @@ constexpr auto equal(InputIterator1 first1, sentinel_for<InputIterator1> auto co
117134
}
118135

119136
export template<iterator InputIterator1, iterator InputIterator2>
120-
constexpr auto equal(InputIterator1 const first1, sentinel_for<InputIterator1> auto const last1, InputIterator2 const first2) {
121-
return ::containers::equal(first1, last1, first2, bounded::equal_to());
137+
constexpr auto equal(InputIterator1 first1, sentinel_for<InputIterator1> auto last1, InputIterator2 first2) {
138+
return ::containers::equal(
139+
std::move(first1),
140+
std::move(last1),
141+
std::move(first2),
142+
bounded::equal_to()
143+
);
122144
}
123145

124146
export template<range Range1, range Range2>

0 commit comments

Comments
 (0)