Namespaces
Variants

operator==,!=,<,<=,>,>=,<=> (std::move_iterator)

From cppreference.net
Iterator library
Iterator concepts
Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
Range access
(C++11) (C++14)
(C++14) (C++14)
(C++11) (C++14)
(C++14) (C++14)
(C++17) (C++20)
(C++17)
(C++17)
**日本語訳:** - HTMLタグ、属性、` `、`
`、``タグ内のテキストは翻訳せず、元のフォーマットを保持
- C++固有の用語は翻訳せず、精度と専門性を重視
**翻訳結果:**
template < class Iter1, class Iter2 >

bool operator == ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
**注釈:** - コード部分はすべて原文のまま保持 - 数値の「(1)」と「(constexpr since C++17)」はC++仕様の一部として翻訳せず保持 - HTML構造とC++コードは完全に元のまま維持 (注:このHTML要素には翻訳対象のテキストコンテンツが含まれていないため、元の構造を保持したまま出力します)
定義済みヘッダー <iterator>
template < class Iter1, class Iter2 >

bool operator == ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
(1) (constexpr since C++17)
(1) (constexpr since C++17)
template < class Iter1, class Iter2 >

bool operator ! = ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
(2) (constexpr since C++17)
(until C++20)
template < class Iter1, class Iter2 >

bool operator < ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
(3) (constexpr since C++17)
template < class Iter1, class Iter2 >

bool operator <= ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
(4) (C++17以降 constexpr)
template < class Iter1, class Iter2 >

bool operator > ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
(5) (constexpr since C++17)
template < class Iter1, class Iter2 >

bool operator >= ( const std:: move_iterator < Iter1 > & lhs,

const std:: move_iterator < Iter2 > & rhs ) ;
(6) (C++17以降 constexpr)
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 に変換可能である場合。

!= 演算子は operator== から合成されます

(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」と「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 );
}

関連項目

基となるイテレータと基となるセンチネルを比較する
(関数テンプレート)