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

来自cppreference.com
 
 
迭代器库
迭代器概念
迭代器原语
算法概念与工具
间接可调用概念
常用算法要求
(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< std::sentinel_for<Iter> S >
constexpr bool operator==( const S& s ) const;
(1) (C++23 起)
两个 basic_const_iterator 之间的关系比较
constexpr bool operator<( const basic_const_iterator& y ) const
    requires std::random_access_iterator<Iter>;
(2) (C++23 起)
constexpr bool operator>( const basic_const_iterator& y ) const
    requires std::random_access_iterator<Iter>;
(3) (C++23 起)
constexpr bool operator<=( const basic_const_iterator& y ) const
    requires std::random_access_iterator<Iter>;
(4) (C++23 起)
constexpr bool operator>=( const basic_const_iterator& y ) const
    requires std::random_access_iterator<Iter>;
(5) (C++23 起)
constexpr auto operator<=>( const basic_const_iterator& y ) const
    requires std::random_access_iterator<Iter> && std::three_way_comparable<Iter>;
(6) (C++23 起)
basic_const_iterator 和另一类型之间的关系比较
template< /*different-from*/<basic_const_iterator> I >

constexpr bool operator<( const I& y ) const

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(7) (C++23 起)
template< /*different-from*/<basic_const_iterator> I >

constexpr bool operator>( const I& y ) const

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(8) (C++23 起)
template< /*different-from*/<basic_const_iterator> I >

constexpr bool operator<=( const I& y ) const

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(9) (C++23 起)
template< /*different-from*/<basic_const_iterator> I >

constexpr bool operator>=( const I& y ) const

    requires std::random_access_iterator<Iter> && std::totally_ordered_with<Iter, I>;
(10) (C++23 起)
template< /*different-from*/<basic_const_iterator> I >

constexpr auto operator<=>( const I& y ) const
    requires std::random_access_iterator<Iter> &&
        std::totally_ordered_with<Iter, I> &&

        std::three_way_comparable_with<Iter, I>;
(11) (C++23 起)

比较 basic_const_iterator 和另一个值。

!= 运算符从 operator== 运算符合成

std::same_as<I, basic_const_iterator<Iter>> 为 false 时 I 满足 /*different-from*/<basic_const_iterator>

参数

s - Iter 的哨位
y - 要与之比较的值

返回值

1) base() == s
2) base() < y.base()
3) base() > y.base()
4) base() <= y.base()
5) base() >= y.base()
6) base() <=> y.base()
7) base() < y
8) base() > y
9) base() <= y
10) base() >= y
11) base() <=> y

注解

Iter 实现了 sentinel_for<Iter> 时,重载 (1) 可用于比较两个 basic_const_iterator<Iter> 值。

示例

参阅