operator<,<=,>,>=(std::basic_const_iterator<Iter>)
来自cppreference.com
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 不是 basic_const_iterator 的特化时,它满足仅用于阐释的概念 /*not-a-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);
}
参阅
| |||