名稱空間
變體
操作

operator<,<=,>,>=(std::basic_const_iterator<Iter>)

來自 cppreference.com
 
 
迭代器庫
迭代器概念
迭代器原語
演算法概念與工具
間接可呼叫概念
常用演算法要求
(C++20)
(C++20)
(C++20)
工具
(C++20)
迭代器介面卡
範圍訪問
(C++11)(C++14)
(C++14)(C++14)  
(C++11)(C++14)
(C++14)(C++14)  
(C++17)(C++20)
(C++17)
(C++17)
 
 
template< /*not-a-const-iterator*/ I >

friend constexpr bool operator<( const I& x, const basic_const_iterator& y )

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(1) (C++23 起)
template< /*not-a-const-iterator*/ I >

friend constexpr bool operator>( const I& x, const basic_const_iterator& y )

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(2) (C++23 起)
template< /*not-a-const-iterator*/ I >

friend constexpr bool operator<=( const I& x, const basic_const_iterator& y )

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(3) (C++23 起)
template< /*not-a-const-iterator*/ I >

friend constexpr bool operator>=( const I& x, const basic_const_iterator& y )

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(4) (C++23 起)

basic_const_iterator 與另一個值進行比較。當左運算元不是 basic_const_iterator 時,使用這些函式模板。

I 滿足僅用於說明的概念 /*not-a-const-iterator*/ 當且僅當它不是 basic_const_iterator 的特化。

這些函式對普通的非限定限定查詢不可見,只能透過實參依賴查詢basic_const_iterator<Iter> 是實參的關聯類時找到。

目錄

[編輯] 引數

x, y - 要比較的迭代器

[編輯] 返回值

1) x < y.base()
2) x > y.base()
3) x <= y.base()
4) x >= y.base()

[編輯] 註解

如果左運算元是 basic_const_iterator,則使用成員比較函式

[編輯] 示例

#include <iterator>
 
int main()
{
    static int arr[1];
    static constexpr std::basic_const_iterator<int*> it = std::end(arr);
    static_assert(arr < it);
}

[編輯] 另見