命名空间
变体
操作

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

来自 cppreference.cn
 
 
迭代器库
迭代器概念
迭代器原语
算法概念和工具
间接可调用概念
通用算法要求
(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);
}

[编辑] 参见