Spec-Zone.ru › C++

std::ranges::chunk_view<V>::iterator<Const>::operator++,--,+=,-=

constexpr /*iterator*/& operator++();
(1) (с C++23)
constexpr /*iterator*/ operator++( int );
(2) (с C++23)
constexpr /*iterator*/& operator--()
    requires ranges::bidirectional_range<Base>;
(3) (с C++23)
constexpr /*iterator*/ operator--( int )
    requires ranges::bidirectional_range<Base>;
(4) (с C++23)
constexpr /*iterator*/& operator+=( difference_type x )
    requires ranges::random_access_range<Base>;
(5) (с C++23)
constexpr /*iterator*/& operator-=( difference_type x )
    requires ranges::random_access_range<Base>;
(6) (с C++23)

Перемещает итератор вперёд или назад.

Пусть current_, end_, и n_ — базовые члены данных chunk_view::iterator.

1) Эквивалентно:
missing_ = ranges::advance(current_, n_, end_);
return *this;
Перед вызовом выражение current_ != end_ должно быть true, в противном случае поведение не определено.
2) Эквивалентно: auto tmp = *this; ++*this; return tmp;.
3) Эквивалентно:
ranges::advance(current_, missing_ - n_);
missing_ = 0;
return *this;
4) Эквивалентно: auto tmp = *this; --*this; return tmp;.
5) Эквивалентно:
if (x > 0)
{
    ranges::advance(current_, n_ * (x - 1));
    missing_ = ranges::advance(current_, n_, end_);
}
else if (x < 0)
{
    ranges::advance(current_, n_ * x + missing_);
    missing_ = 0;
}
return *this;
Если x положительно, то перед вызовом выражение ranges::distance(current_, end_) > n_ * (x - 1) должно быть true (т.е., неформально, запрашиваемый фрагмент должен находиться «внутри» базовой последовательности). Если x отрицательно, это предварительное условие всегда выполняется.
6) Эквивалентно: return *this += -x;.

Параметры

x - позиция, смещающая текущую позицию

Возвращаемое значение

1,3,5,6) *this
2,4) копия *this, сделанная до изменения

Пример

См. также

operator+operator-
(C++23)
выполняет арифметику итераторов
(функция)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/ranges/chunk_view/iterator/operator_arith

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API