[ Web Proxy ]
URL:
Viewing: https://de.cppreference.com/cpp/utility/tuple/operator_cmp [Back]  [Original]

operator==,!=,<,<=,>,>=(std::tuple) cppreference.com
cppreference.com
Namensrume
Varianten

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

Aus cppreference.com

<metanoindex/>

 
 
 
std::tuple
Member-Funktionen
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple::tuple
tuple::operator=
tuple::swap
Non-Member-Funktionen
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
make_tuple
tie
forward_as_tuple
None
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get
Helper-Klassen
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple_size
tuple_element
uses_allocator
ignore
 
<tbody> </tbody>
definiert in Header <tuple>
template< class... TTypes, class... UTypes > bool operator==( const tuple<TTypes...>& lhs, const tuple<UTypes...>& rhs );
(1) (seit C++11)
template< class... TTypes, class... UTypes > bool operator!=( const tuple<TTypes...>& lhs, const tuple<UTypes...>& rhs );
(2) (seit C++11)
template< class... TTypes, class... UTypes > bool operator<( const tuple<TTypes...>& lhs, const tuple<UTypes...>& rhs );
(3) (seit C++11)
template< class... TTypes, class... UTypes > bool operator<=( const tuple<TTypes...>& lhs, const tuple<UTypes...>& rhs );
(5) (seit C++11)
template< class... TTypes, class... UTypes > bool operator>( const tuple<TTypes...>& lhs, const tuple<UTypes...>& rhs );
(4) (seit C++11)
template< class... TTypes, class... UTypes > bool operator>=( const tuple<TTypes...>& lhs, const tuple<UTypes...>& rhs );
(6) (seit C++11)

1-2)

Vergleicht jedes Element des Tupels lhs mit dem entsprechenden Element des Tupels rhs .
Original:
Compares every element of the tuple lhs with the corresponding element of the tuple rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3-6)

Vergleicht und lhs rhs lexikographisch, dh vergleicht die ersten Elemente, wenn sie quivalent sind, vergleicht die zweiten Elemente, wenn diejenigen quivalent sind, vergleicht die dritten Elemente und so weiter .
Original:
Compares lhs and rhs lexicographically, that is, compares the first elements, if they are equivalent, compares the second elements, if those are equivalent, compares the third elements, and so on.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Alle Vergleichsoperatoren kurzgeschlossen sind, sie greifen nicht auf Tupel-Elemente jenseits, was notwendig ist, um das Ergebnis des Vergleichs zu ermitteln .
Original:
All comparison operators are short-circuited; they do not access tuple elements beyond what is necessary to determine the result of the comparison.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parameter

lhs, rhs -
Tupeln zu vergleichen
Original:
tuples to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Rckgabewert

1)

true wenn std::get<i>(lhs) == std::get<i>(rhs) fr alle i in [0, sizeof...(Types)), sonst false. Fr zwei leere Tupel kehrt true .
Original:
true if std::get<i>(lhs) == std::get<i>(rhs) for all i in [0, sizeof...(Types)), otherwise false. For two empty tuples returns true.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2) !(lhs == rhs)

3)

(bool)(std::get<0>(lhs) < std::get<0>(rhs)) || (!(bool)(std::get<0>(rhs) < std::get<0>(lhs)) && lhstail < rhstail), wo lhstail ist lhs ohne seine erste Element, und rhstail ist rhs ohne dessen erstes Element. Fr zwei leere Tupel, kehrt false .
Original:
(bool)(std::get<0>(lhs) < std::get<0>(rhs)) || (!(bool)(std::get<0>(rhs) < std::get<0>(lhs)) && lhstail < rhstail), where lhstail is lhs without its first element, and rhstail is rhs without its first element. For two empty tuples, returns false.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

4) !(lhs < rhs)

5) rhs < lhs

6) !(rhs < lhs)

Beispiel

Da operator <fr Tupel definiert ist, knnen Container von Tupeln sortiert werden .
Original:
Because operator< is defined for tuples, containers of tuples can be sorted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
int main()
{
    std::vector<std::tuple<int, std::string, float>> v;
    v.emplace_back(2, "baz", -0.1);
    v.emplace_back(2, "bar", 3.14);
    v.emplace_back(1, "foo", 100.1);
    std::sort(v.begin(), v.end());

    for(auto p: v) {
        std::cout << "(" << std::get<0>(p) << ", " << std::get<1>(p)
                  << ", " << std::get<2>(p) << ")\n";
    }
}

Output:

(1, foo, 100.1)
(2, bar, 3.14)
(2, baz, -0.1)

Siehe auch


Web Proxy Viewer  |  New URL  |  Original Page