operator-(ranges::adjacent_view::sentinel)

< cpp‎ | ranges‎ | adjacent view‎ | sentinel
template< bool OtherConst >

  requires std::sized_sentinel_for<ranges::sentinel_t<Base>,
                                   ranges::iterator_t<__maybe_const<OtherConst, V>>>
friend constexpr ranges::range_difference_t<__maybe_const<OtherConst, V>>

  operator-( const /*iterator*/<OtherConst>& x, const /*sentinel*/& y );
(1) (C++23 起)
template< bool OtherConst >

  requires std::sized_sentinel_for<ranges::sentinel_t<Base>,
                                   ranges::iterator_t<__maybe_const<OtherConst, V>>>
friend constexpr ranges::range_difference_t<__maybe_const<OtherConst, V>>

  operator-( const /*sentinel*/& y, const /*iterator*/<OtherConst>& x );
(2) (C++23 起)

计算 x 的底层迭代器和 y 的底层哨位之间的距离。

current_ 指代 x 的底层迭代器数组,并且 end_ 指代 y 的底层哨位。

1) 等价于 return x.current_.back() - y.end_;
2) 等价于 return y.end_ - x.current_.back();

这些函数模板对通常无限定有限定查找不可见,而只能在 adjacent_view::sentinel 为参数的关联类时由实参依赖查找找到。

参数

x - 迭代器
y - 哨位

返回值

xy 之间的距离。

示例

参阅