名稱空間
變體
操作

operator-(std::counted_iterator<I>, std::default_sentinel_t)

來自 cppreference.com
 
 
迭代器庫
迭代器概念
迭代器原語
演算法概念與工具
間接可呼叫概念
常用演算法要求
工具
迭代器介面卡
 
 
friend constexpr std::iter_difference_t<I> operator-(
    const counted_iterator& x, std::default_sentinel_t );
(1) (C++20 起)
friend constexpr std::iter_difference_t<I> operator-(
    std::default_sentinel_t, const counted_iterator& y );
(2) (C++20 起)
1) 返回到末尾的負距離。
2) 返回到末尾的正距離。

此函式模板對於普通的非限定限定查詢不可見,只能透過實參依賴查詢在 std::counted_iterator<I> 是實參的關聯類時找到。

目錄

[編輯] 引數

x, y - 要計算差異的迭代器介面卡

[編輯] 返回值

1) -x.count()
2) y.count()

[編輯] 示例

#include <initializer_list>
#include <iterator>
 
int main()
{
    constexpr static auto v = {1, 2, 3, 4};
    constexpr std::counted_iterator<std::initializer_list<int>::iterator>
        it{v.begin(), 3};
    constexpr auto d1 = it - std::default_sentinel;
    static_assert(d1 == -3); // (1)
    constexpr auto d2 = std::default_sentinel - it;
    static_assert(d2 == +3); // (2)
}

[編輯] 參閱

遞增或遞減 counted_iterator
(public member function) [編輯]
前進迭代器
(function template) [編輯]
計算兩個迭代器介面卡之間的距離
(function template) [編輯]
用於知道其範圍邊界的迭代器的預設哨兵
(class) [編輯]