Namespace
Varianti

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

Da cppreference.com.
< cpp‎ | utility‎ | tuple

 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
std::tuple
Membri funzioni
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 membri funzioni
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 classi
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
 
Defined in header <tuple>
template< class... TTypes, class... UTypes >

bool operator==( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(1) (dal C++11)
template< class... TTypes, class... UTypes >

bool operator!=( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(2) (dal C++11)
template< class... TTypes, class... UTypes >

bool operator<( const tuple<TTypes...>& lhs,

                const tuple<UTypes...>& rhs );
(3) (dal C++11)
template< class... TTypes, class... UTypes >

bool operator<=( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(5) (dal C++11)
template< class... TTypes, class... UTypes >

bool operator>( const tuple<TTypes...>& lhs,

                const tuple<UTypes...>& rhs );
(4) (dal C++11)
template< class... TTypes, class... UTypes >

bool operator>=( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(6) (dal C++11)
1-2)
Confronta ogni elemento del lhs tupla con l'elemento corrispondente della rhs tupla.
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)
Confronta lhs e rhs lessicografico, cioè, a confronto i primi elementi, se sono equivalenti, confronta i secondi elementi, se questi sono equivalenti, confronta i terzi elementi, e così via.
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.
Tutti gli operatori di confronto sono in corto circuito e non accedere agli elementi di tuple al di là di quanto è necessario per determinare il risultato del confronto.
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.

Indice

[modifica] Parametri

lhs, rhs -
tuple da confrontare
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.

[modifica] Valore di ritorno

1)
true std::get<i>(lhs) == std::get<i>(rhs) se per ogni i in [0, sizeof...(Types)), altrimenti false. Per due corse a vuoto dei tuple 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), dove è lhstail ss senza il suo primo elemento, e rhstail è sd senza il suo primo elemento. Per due tuple vuote, restituisce 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)

[modifica] Esempio

Perché <operatore è definito per le tuple, contenitori di tuple possono essere ordinati .
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)

[modifica] Vedi anche