operator+,-(ranges::concat_view::iterator)
来自 zh.cppreference.net
friend constexpr /*iterator*/
operator+( const /*iterator*/& it, difference_type n )
requires /*concat-is-random-access*/<Const, Views...>;
|
(1) | (自 C++26 起) |
friend constexpr /*iterator*/
operator+( difference_type n, const /*iterator*/& it )
requires /*concat-is-random-access*/<Const, Views...>;
|
(2) | (自 C++26 起) |
friend constexpr /*iterator*/
operator-( const /*iterator*/& it, difference_type n )
requires /*concat-is-random-access*/<Const, Views...>;
|
(3) | (自 C++26 起) |
friend constexpr difference_type
operator-( const /*iterator*/& x, const /*iterator*/& y )
requires /*concat-is-random-access*/<Const, Views...>;
|
(4) | (自 C++26 起) |
friend constexpr difference_type
operator-( const /*iterator*/& x, std::default_sentinel_t )
requires /* see description */;
|
(5) | (自 C++26 起) |
friend constexpr difference_type
operator-( std::default_sentinel_t, const /*iterator*/& x )
requires /* see description */;
|
(6) | (自 C++26 起) |
递增或递减迭代器。
1) 等价于
auto t = it; t += n; return t;.2) 等价于
return it + n;.3) 等价于
auto t = it; t -= n; return t;.4) 设
Ix 为 x.it_ .index(),Iy 为 y.it_ .index():
- 如果
Ix > Iy是true,则等价于difference_type result = ranges::distance(y.get-iter<Iy>(), y.get-end<Iy>());for (std::size_t I = Iy + 1; I < Ix; I++)result += ranges::distance(x.get-view<I>());return result + ranges::distance(x.get-begin<Ix>(), x.get-iter<Ix>());. - 否则,如果
Ix < Iy是true,则等价于return -(y - x);. - 否则,等价于
return x.get-iter<Ix>() - y.get-iter<Iy>();.
5) 设
Ix 为 x.it_ .index(),等价于 difference_type result = ranges::distance(x.get-iter <Ix>(), x.get-end <Ix>());for (std::size_t I = Ix + 1, count = sizeof...(Views); I < count; I++) result += ranges::distance(x.get-view <I>());return -result;. 设
Fs 为包含 Views 中除首个元素外的所有元素的包,则 requires 子句中的表达式等价于
(std::sized_sentinel_for<ranges::sentinel_t<maybe-const <Const, Views>>,
ranges::iterator_t<maybe-const <Const, Views>>> && ...) &&
(ranges::sized_range<maybe-const <Const, Fs>> && ...)
如果
x.it_ .valueless_by_exception() 是 true,则行为未定义。6) 等价于
return -(x - std::default_sentinel);. 设
Fs 为包含 Views 中除首个元素外的所有元素的包,则 requires 子句中的表达式等价于
(std::sized_sentinel_for<ranges::sentinel_t<maybe-const <Const, Views>>,
ranges::iterator_t<maybe-const <Const, Views>>> && ...) &&
(ranges::sized_range<maybe-const <Const, Fs>> && ...)
如果
x.it_ .valueless_by_exception() 是 true,则行为未定义。这些函数对于普通的无限定查找或限定查找不可见,并且只能通过参数依赖查找找到,前提是concat_view::iterator <Const>是参数的关联类。
参数
| it, x, y | - | 迭代器 |
| n | - | 相对于当前位置的偏移量 |
返回值
如上所述。
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
前进或后退底层迭代器
(公开成员函数) |