operator==,!=,<,<=,>,>=,<=> (std::move_iterator)
|
定义于头文件
<iterator>
|
||
|
template
<
class
Iter1,
class
Iter2
>
bool
operator
==
(
const
std::
move_iterator
<
Iter1
>
&
lhs,
|
(1) | (C++17 起为 constexpr) |
|
template
<
class
Iter1,
class
Iter2
>
bool
operator
!
=
(
const
std::
move_iterator
<
Iter1
>
&
lhs,
|
(2) |
(C++17 起为 constexpr)
(C++20 前) |
|
template
<
class
Iter1,
class
Iter2
>
bool
operator
<
(
const
std::
move_iterator
<
Iter1
>
&
lhs,
|
(3) | (C++17 起为 constexpr) |
|
template
<
class
Iter1,
class
Iter2
>
bool
operator
<=
(
const
std::
move_iterator
<
Iter1
>
&
lhs,
|
(4) | (C++17 起为 constexpr) |
|
template
<
class
Iter1,
class
Iter2
>
bool
operator
>
(
const
std::
move_iterator
<
Iter1
>
&
lhs,
|
(5) | (C++17 起为 constexpr) |
|
template
<
class
Iter1,
class
Iter2
>
bool
operator
>=
(
const
std::
move_iterator
<
Iter1
>
&
lhs,
|
(6) | (C++17 起为 constexpr) |
|
template
<
class
Iter1,
std::
three_way_comparable_with
<
Iter1
>
Iter2
>
constexpr
std::
compare_three_way_result_t
<
Iter1, Iter2
>
|
(7) | (C++20 起) |
比较 lhs 与 rhs 的底层迭代器。
|
1)
仅当
lhs.
base
(
)
==
rhs.
base
(
)
格式正确且可转换为
bool
时,此重载参与重载决议。
3-6)
仅当
lhs.
base
(
)
<
rhs.
base
(
)
格式正确且可转换为
bool
时,这些重载参与重载决议。
|
(C++20 起) |
目录 |
参数
| lhs, rhs | - | 用于比较的迭代器适配器 |
返回值
示例
#include <cassert> #include <iterator> int main() { int a[]{9, 8, 7, 6}; // │ └───── x, y // └──────── z // “x”与“y”相等,但“x”大于“z” std::move_iterator<int*> x{std::end(a) - 1}, y{std::end(a) - 1}, z{std::end(a) - 2}; // 双向比较 assert( x == y ); assert(!(x != y)); assert(!(x < y)); assert( x <= y ); assert(!(x == z)); assert( x != z ); assert(!(x < z)); assert(!(x <= z)); // 三向比较 assert( x <=> y == 0 ); assert(!(x <=> y < 0)); assert(!(x <=> y > 0)); assert(!(x <=> z == 0)); assert(!(x <=> z < 0)); assert( x <=> z > 0 ); }
参见
|
(C++20)
|
比较底层迭代器与底层哨兵
(函数模板) |