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)
(Anmerkung: Der bereitgestellte HTML-Code enthält keinen übersetzbaren Text, da alle Tags und Attribute gemäß den Anweisungen unverändert bleiben sollen und die Tabellenzellen leer sind.)
Definiert im Header <iterator>
template < class Iter1, class Iter2 >

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

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

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

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

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

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

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

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

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

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

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

const std:: move_iterator < Iter2 > & rhs ) ;
(6) (constexpr seit 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) (seit C++20)

Vergleicht die zugrundeliegenden Iteratoren von lhs und rhs .

1) Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn lhs. base ( ) == rhs. base ( ) wohlgeformt und konvertierbar zu bool ist.
3-6) Diese Überladungen nehmen nur dann an der Überladungsauflösung teil, wenn lhs. base ( ) < rhs. base ( ) wohlgeformt und konvertierbar zu bool ist.

Der != -Operator wird aus operator== synthetisiert .

(seit C++20)

Inhaltsverzeichnis

Parameter

lhs, rhs - Iterator-Adapter zum Vergleichen

Rückgabewert

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 ( )

Beispiel

#include <cassert>
#include <iterator>
int main()
{
    int a[]{9, 8, 7, 6};
    //            │  └───── x, y
    //            └──────── z
    // “x” und “y” sind gleich, aber “x” ist größer als “z”
    std::move_iterator<int*>
        x{std::end(a) - 1},
        y{std::end(a) - 1},
        z{std::end(a) - 2};
    // Zweiwege-Vergleiche
    assert(  x == y );
    assert(!(x != y));
    assert(!(x <  y));
    assert(  x <= y );
    assert(!(x == z));
    assert(  x != z );
    assert(!(x <  z));
    assert(!(x <= z));
    // Dreiwege-Vergleiche
    assert(  x <=> y == 0 );
    assert(!(x <=> y <  0));
    assert(!(x <=> y >  0));
    assert(!(x <=> z == 0));
    assert(!(x <=> z <  0));
    assert(  x <=> z >  0 );
}

Siehe auch

vergleicht den zugrundeliegenden Iterator und den zugrundeliegenden Sentinel
(Funktions-Template)