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)
헤더 파일에 정의됨 <iterator>
template < class Iter1, class Iter2 >

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

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

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

const std:: move_iterator < Iter2 > & rhs ) ;
(2) (C++17부터 constexpr)
(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) (C++17부터 constexpr)
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== 로부터 생성됩니다.

(since 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 );
}

참고 항목

기본 반복자와 기본 센티널을 비교함
(함수 템플릿)