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