命名空间
变体
操作

operator-(ranges::adjacent_view::sentinel)

来自 cppreference.cn
< 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) (since 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) (since 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 之间的距离。

[编辑] 示例

[编辑] 参见