Namespaces
Variants

operator-(ranges::adjacent_view::sentinel)

来自 zh.cppreference.net
 
 
范围库
范围适配器
 
 
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 - 一个 iterator
y - 一个 sentinel

返回值

x 与 y 之间的距离。

示例

参见