operator<,<=,>,>=(std::basic_const_iterator<Iter>)
來自 cppreference.com
< cpp | 迭代器 | basic_const_iterator
template< /*not-a-const-iterator*/ I > friend constexpr bool operator<( const I& x, const basic_const_iterator& y ) |
(1) | (C++23 起) |
template< /*not-a-const-iterator*/ I > friend constexpr bool operator>( const I& x, const basic_const_iterator& y ) |
(2) | (C++23 起) |
template< /*not-a-const-iterator*/ I > friend constexpr bool operator<=( const I& x, const basic_const_iterator& y ) |
(3) | (C++23 起) |
template< /*not-a-const-iterator*/ I > friend constexpr bool operator>=( const I& x, const basic_const_iterator& y ) |
(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); }
[編輯] 另見
|