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

来自cppreference.com
< cpp‎ | ranges‎ | stride view‎ | iterator
 
 
范围库
范围适配器
 
 
constexpr /*iterator*/& operator++();
(1) (C++23 起)
constexpr void operator++( int );
(2) (C++23 起)
constexpr /*iterator*/ operator++( int )
    requires ranges::forward_range<Base>;
(3) (C++23 起)
constexpr /*iterator*/& operator--()
    requires ranges::bidirectional_range<Base>;
(4) (C++23 起)
constexpr /*iterator*/ operator--( int )
    requires ranges::bidirectional_range<Base>;
(5) (C++23 起)
constexpr /*iterator*/& operator+=( difference_type n )
    requires ranges::random_access_range<Base>;
(6) (C++23 起)
constexpr /*iterator*/& operator-=( difference_type n )
    requires ranges::random_access_range<Base>;
(7) (C++23 起)

增加或减小迭代器

current_end_stride_,与 missing_迭代器的数据成员,

1) 等价于
missing_ = ranges::advance(current_, stride_, end_);
return *this
current_ 调用前不能等于 end_
2) 等价于 ++*this;
3) 等价于 auto tmp = *this; ++*this; return tmp;
4) 等价于
ranges::advance(current_, missing_ - stride_);
missing_ = 0;
return *this;
5) 等价于 auto tmp = *this; --*this; return tmp;
6) 等价于
if (n > 0)
{
    ranges::advance(current_, stride_ * (n - 1));
    missing_ = ranges::advance(current_, stride_, end_);
}
else if (n < 0)
{
    ranges::advance(current_, stride_ * n + missing_);
    missing_ = 0;
}
 
return *this;

如果 n > 0,那么调用此函数前 ranges::distance(current_, end_) 必须大于 stride_ * (n - 1)

请注意,如果 n < 0,那么 ranges::distance(current_, end_) 总是大于(非正)stride_ * (n - 1)
7) 等价于 return *this += -n;

参数

n - 相对于当前位置的位移

返回值

1,4,6,7) *this
2) (无)
3,5) *this 被修改前的副本

示例

参阅

performs iterator arithmetic
(函数)