Skip to content

Commit 3c9f800

Browse files
committed
Address review comments about set_intersection.h: unnecessary namespace qualification, insufficient comments, and direct use of iterator traits.
1 parent 161d81c commit 3c9f800

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

libcxx/include/__algorithm/set_intersection.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ struct _LIBCPP_NODISCARD __set_intersector {
134134
}
135135
};
136136

137-
// with forward iterators we can use binary search to skip over entries
137+
// with forward iterators we can make multiple passes over the data, allowing the use of one-sided binary search to reduce best-case
138+
// complexity to log(N)
138139
template <class _AlgPolicy,
139140
class _Compare,
140141
class _InForwardIter1,
@@ -190,25 +191,12 @@ __set_intersection(
190191
}
191192
}
192193

193-
return std::__set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>(
194+
return __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>(
194195
_IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)),
195196
_IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)),
196197
std::move(__result));
197198
}
198199

199-
template <class _AlgPolicy, class _Iter>
200-
class __set_intersection_iter_category {
201-
template <class _It>
202-
using __cat = typename std::_IterOps<_AlgPolicy>::template __iterator_category<_It>;
203-
template <class _It>
204-
static __cat<_It> test(__cat<_It>*);
205-
template <class>
206-
static std::input_iterator_tag test(...);
207-
208-
public:
209-
using __type = decltype(test<_Iter>(nullptr));
210-
};
211-
212200
template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
213201
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI
214202
_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>
@@ -221,8 +209,8 @@ __set_intersection(
221209
std::move(__last2),
222210
std::move(__result),
223211
__comp,
224-
typename std::__set_intersection_iter_category<_AlgPolicy, _InIter1>::__type(),
225-
typename std::__set_intersection_iter_category<_AlgPolicy, _InIter2>::__type());
212+
typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter1>(),
213+
typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter2>());
226214
}
227215

228216
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>

0 commit comments

Comments
 (0)