Skip to content

Commit 4588447

Browse files
committed
Rename new sentinel-based _IterOps::advance() to _IterOps::__advance_to -- no reason IMO to have a second override if __advance_to = ranges::advance in c++20...
1 parent 613e64a commit 4588447

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libcxx/include/__algorithm/iterator_operations.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ struct _IterOps<_ClassicAlgPolicy> {
9191
// use the incoming type for returning and steer clear of negative overflows
9292
template <class _Iter, class _Distance>
9393
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static _Distance
94-
advance(_Iter& __iter, _Distance __count, const _Iter& __sentinel) {
95-
return _IterOps::__advance(__iter, __count, __sentinel, typename iterator_traits<_Iter>::iterator_category());
94+
__advance_to(_Iter& __iter, _Distance __count, const _Iter& __sentinel) {
95+
return _IterOps::__advance_to(__iter, __count, __sentinel, typename iterator_traits<_Iter>::iterator_category());
9696
}
9797

9898
private:
9999
// advance with sentinel, a la std::ranges::advance -- InputIterator specialization
100100
template <class _InputIter, class _Distance>
101101
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static _Distance
102-
__advance(_InputIter& __iter, _Distance __count, const _InputIter& __sentinel, input_iterator_tag) {
102+
__advance_to(_InputIter& __iter, _Distance __count, const _InputIter& __sentinel, input_iterator_tag) {
103103
_Distance __dist = _Distance();
104104
for (; __dist < __count && __iter != __sentinel; ++__dist)
105105
++__iter;
@@ -109,7 +109,7 @@ struct _IterOps<_ClassicAlgPolicy> {
109109
// advance with sentinel, a la std::ranges::advance -- BidirectionalIterator specialization
110110
template <class _BiDirIter, class _Distance>
111111
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static _Distance
112-
__advance(_BiDirIter& __iter, _Distance __count, const _BiDirIter& __sentinel, bidirectional_iterator_tag) {
112+
__advance_to(_BiDirIter& __iter, _Distance __count, const _BiDirIter& __sentinel, bidirectional_iterator_tag) {
113113
_Distance __dist = _Distance();
114114
if (__count >= 0)
115115
for (; __dist < __count && __iter != __sentinel; ++__dist)
@@ -123,7 +123,7 @@ struct _IterOps<_ClassicAlgPolicy> {
123123
// advance with sentinel, a la std::ranges::advance -- RandomIterator specialization
124124
template <class _RandIter, class _Distance>
125125
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static _Distance
126-
__advance(_RandIter& __iter, _Distance __count, const _RandIter& __sentinel, random_access_iterator_tag) {
126+
__advance_to(_RandIter& __iter, _Distance __count, const _RandIter& __sentinel, random_access_iterator_tag) {
127127
auto __dist = _IterOps::distance(__iter, __sentinel);
128128
_LIBCPP_ASSERT_VALID_INPUT_RANGE(
129129
__count == 0 || (__dist < 0) == (__count < 0), "__sentinel must precede __iter when __count < 0");

libcxx/include/__algorithm/lower_bound.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ __lower_bound_onesided(_Iter __first, _Sent __last, const _Type& __value, _Comp&
7171
using _Distance = typename iterator_traits<_Iter>::difference_type;
7272
for (_Distance __step = 1; __first != __last; __step <<= 1) {
7373
auto __it = __first;
74-
auto __dist = __step - _IterOps<_AlgPolicy>::advance(__it, __step, __last);
74+
auto __dist = __step - _IterOps<_AlgPolicy>::__advance_to(__it, __step, __last);
7575
// once we reach the last range where needle can be we must start
7676
// looking inwards, bisecting that range
7777
if (__it == __last || !std::__invoke(__comp, std::__invoke(__proj, *__it), __value)) {

0 commit comments

Comments
 (0)