@@ -57,18 +57,14 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lo
57
57
// would yield \Omega(n*log(n)) comparisons and, for non-random iterators, \Omega(n^2) iterator increments, whereas the
58
58
// one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of
59
59
// comparisons.
60
- template <class _AlgPolicy , class _Iter , class _Sent , class _Type , class _Proj , class _Comp >
61
- _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
62
- __lower_bound_onesided (_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
63
- // static_assert(std::is_base_of<std::forward_iterator_tag, typename _IterOps<_AlgPolicy>::template
64
- // __iterator_category<_Iter>>::value,
65
- // "lower_bound() is a multipass algorithm and requires forward iterator or better");
66
-
60
+ template <class _AlgPolicy , class _ForwardIterator , class _Sent , class _Type , class _Proj , class _Comp >
61
+ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
62
+ __lower_bound_onesided (_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
67
63
// step = 0, ensuring we can always short-circuit when distance is 1 later on
68
64
if (__first == __last || !std::__invoke (__comp, std::__invoke (__proj, *__first), __value))
69
65
return __first;
70
66
71
- using _Distance = typename iterator_traits<_Iter >::difference_type;
67
+ using _Distance = typename iterator_traits<_ForwardIterator >::difference_type;
72
68
for (_Distance __step = 1 ; __first != __last; __step <<= 1 ) {
73
69
auto __it = __first;
74
70
auto __dist = __step - _IterOps<_AlgPolicy>::__advance_to (__it, __step, __last);
@@ -87,9 +83,9 @@ __lower_bound_onesided(_Iter __first, _Sent __last, const _Type& __value, _Comp&
87
83
return __first;
88
84
}
89
85
90
- template <class _AlgPolicy , class _RandIter , class _Sent , class _Type , class _Proj , class _Comp >
91
- _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandIter
92
- __lower_bound (_RandIter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
86
+ template <class _AlgPolicy , class _RandomAccessIterator , class _Sent , class _Type , class _Proj , class _Comp >
87
+ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
88
+ __lower_bound (_RandomAccessIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
93
89
const auto __dist = _IterOps<_AlgPolicy>::distance (__first, __last);
94
90
return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj);
95
91
}
0 commit comments