名稱空間
變體
操作

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

來自 cppreference.com
< cpp‎ | ranges‎ | stride view‎ | iterator
 
 
範圍庫 (Ranges library)
範圍介面卡 (Range adaptors)
 
 
constexpr /*迭代器*/& 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 的一個副本

[編輯] 示例

[編輯] 參閱

進行迭代器算術
(函式)