operator==,!=,<,<=,>,>=,<=>(std::move_iterator)
Определено в заголовке <iterator> | ||
|---|---|---|
template< class Iter1, class Iter2 >
bool operator==( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (1) | (constexpr с C++17) |
template< class Iter1, class Iter2 >
bool operator!=( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (2) |
(constexpr с C++17) (до C++20) |
template< class Iter1, class Iter2 >
bool operator< ( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (3) | (constexpr с C++17) |
template< class Iter1, class Iter2 >
bool operator<=( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (4) | (constexpr с C++17) |
template< class Iter1, class Iter2 >
bool operator> ( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (5) | (constexpr с C++17) |
template< class Iter1, class Iter2 >
bool operator>=( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (6) | (constexpr с C++17) |
template< class Iter1, std::three_way_comparable_with<Iter1> Iter2 >
constexpr std::compare_three_way_result_t<Iter1, Iter2>
operator<=>( const std::move_iterator<Iter1>& lhs,
const std::move_iterator<Iter2>& rhs );
| (7) | (с C++20) |
Сравнивает базовые итераторы lhs и rhs.
1) Эта перегрузка участвует в разрешении перегрузки только в том случае, если lhs.base() == rhs.base() корректно сформировано и преобразуемо к bool. 3-6) Эти перегрузки участвуют в разрешении перегрузки только в том случае, если lhs.base() < rhs.base() корректно сформировано и преобразуемо к bool. Оператор | (с C++20) |
Параметры
| lhs, rhs | - | адаптеры итераторов для сравнения |
Возвращаемое значение
1)
lhs.base() == rhs.base()
2)
!(lhs == rhs)
3)
lhs.base() < rhs.base()
4)
!(rhs < lhs)
5)
rhs < lhs
6)
!(lhs < rhs)
7)
lhs.base() <=> rhs.base()
Пример
#include <cassert>
#include <iterator>
int main()
{
int a[]{9, 8, 7, 6};
// │ └───── x, y
// └──────── z
// “x” and “y” are equal, but “x” is greater than “z”
std::move_iterator<int*>
x{std::end(a) - 1},
y{std::end(a) - 1},
z{std::end(a) - 2};
// two-way comparisons
assert( x == y );
assert(!(x != y));
assert(!(x < y));
assert( x <= y );
assert(!(x == z));
assert( x != z );
assert(!(x < z));
assert(!(x <= z));
// three-way comparisons
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) | сравнивает базовый итератор и базовый sentinel (шаблон функции) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/iterator/move_iterator/operator_cmp