Espaços nominais
Variantes
Acções

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

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

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
initializer_list(C++11)
bitset
hash(C++11)
Os operadores relacionais
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>=
Pares e tuplas
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)
Troque, avançar e avançar
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
Funções de membro
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
Não-membros funções
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
Classes auxiliares
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) (a partir do C++ 11)
template< class... TTypes, class... UTypes >

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

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

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

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

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

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

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

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

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

                 const tuple<UTypes...>& rhs );
(6) (a partir do C++ 11)
1-2)
Compara cada elemento do lhs tupla com o elemento correspondente do 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)
Compara lhs e rhs lexicographically, isto é, compara os primeiros elementos, se eles são equivalentes, compara os segundos elementos, se aqueles são equivalentes, compara os elementos terceiro, e assim por diante.
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.
Todos os operadores de comparação são curto-circuito, pois eles não acessar elementos de tupla, para além do que é necessário para determinar o resultado da comparação.
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.

Índice

[editar] Parâmetros

lhs, rhs -
tuplas para comparar
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.

[editar] Valor de retorno

1)
true se std::get<i>(lhs) == std::get<i>(rhs) para todo i em [0, sizeof...(Types)), caso contrário false. Por dois retornos vazios tuplas 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), onde lhstail é lhs sem seu primeiro elemento, e rhstail é rhs sem seu primeiro elemento. Por duas tuplas vazias, retorna 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)

[editar] Exemplo

Porque <operador é definido para tuplas, recipientes de tuplas podem ser classificados .
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)

[editar] Veja também