operator<,<=,>,>=(std::basic_const_iterator<Iter>)
来自 cppreference.cn
< cpp | iterator | 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); }
[编辑] 参见
|