Namespaces
Variants

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

来自 zh.cppreference.net
 
 
范围库
范围适配器
 
 
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 副本

示例

参见

执行迭代器算术运算
(函数)