名稱空間
變體
操作

operator-(ranges::adjacent_view::sentinel)

來自 cppreference.com
< cpp‎ | ranges‎ | adjacent view‎ | sentinel
 
 
範圍庫 (Ranges library)
範圍介面卡 (Range adaptors)
 
 
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 之間的距離。

[編輯] 示例

[編輯] 參閱