operator==,!=,<,<=,>,>=,<=>(std::move_iterator)
From cppreference.com
< cpp | iterator | 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() がwell-formedで bool に変換可能である場合にのみ、オーバーロード解決に参加します。
3-6) これらのオーバーロードは、lhs.base() < rhs.base() がwell-formedで 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 ); }
[編集] 関連項目
| 基底イテレータと基底センチネルを比較する (関数テンプレート) |