Espaços nominais
Variantes
Ações

std::rel_ops::operator!=,>,<=,>=

De cppreference.com

<metanoindex/>

 
 
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
(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.
(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.
(C++11)
(C++11)
(C++11)
 
<tbody> </tbody>
Definido no cabeçalho <utility>
template< class T > bool operator!=( const T& lhs, const T& rhs );
(1)
template< class T > bool operator>( const T& lhs, const T& rhs );
(2)
template< class T > bool operator<=( const T& lhs, const T& rhs );
(3)
template< class T > bool operator>=( const T& lhs, const T& rhs );
(4)
Dado um definido pelo usuário operator== e operator< para objetos de T tipo, implementa a semântica usual de outros operadores de comparação.
Original:
Given a user-defined operator== and operator< for objects of type T, implements the usual semantics of other comparison operators.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

1)

Implementa operator!= em termos de operator==.
Original:
Implements operator!= in terms of operator==.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Implementa operator> em termos de operator<.
Original:
Implements operator> in terms of operator<.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3)

Implementa operator<= em termos de operator<.
Original:
Implements operator<= in terms of operator<.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

4)

Implementa operator>= em termos de operator<.
Original:
Implements operator>= in terms of operator<.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parâmetros

lhs -
mão esquerda argumento
Original:
left-hand argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rhs -
direito argumento
Original:
right-hand argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

1)

Retorna true se lhs é' não é igual a rhs.
Original:
Returns true if lhs is not equal to rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Retorna true se lhs é maior do que rhs.
Original:
Returns true if lhs is greater than rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3)

Retorna true se lhs é' menor ou igual a rhs.
Original:
Returns true if lhs is less or equal to rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

4)

Retorna true se lhs is' maior ou igual a rhs.
Original:
Returns true if lhs is greater or equal to rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Possível implementação

First version
namespace rel_ops {
    template< class T >
    bool operator!=( const T& lhs, const T& rhs ) 
    {
        return !(lhs == rhs);
    }
}
Second version
namespace rel_ops {
    template< class T >
    bool operator>( const T& lhs, const T& rhs ) 
    {
        return rhs < lhs;
    }
}
Third version
namespace rel_ops {
    template< class T >
    bool operator<=( const T& lhs, const T& rhs ) 
    {
        return !(rhs < lhs);;
    }
}
Fourth version
namespace rel_ops {
    template< class T >
    bool operator>=( const T& lhs, const T& rhs ) 
    {
        return !(lhs < rhs);
    }
}

Exemplo

#include <iostream>
#include <utility>

struct Foo {
    int n;
};

bool operator==(const Foo& lhs, const Foo& rhs)
{
    return lhs.n == rhs.n;
}

bool operator<(const Foo& lhs, const Foo& rhs)
{
    return lhs.n < rhs.n;
}

int main()
{
    Foo f1 = {1};
    Foo f2 = {2};
    using namespace std::rel_ops;

    std::cout << std::boolalpha;
    std::cout << "not equal?     : " << (bool) (f1 != f2) << '\n';
    std::cout << "greater?       : " << (bool) (f1 > f2) << '\n';
    std::cout << "less equal?    : " << (bool) (f1 <= f2) << '\n';
    std::cout << "greater equal? : " << (bool) (f1 >= f2) << '\n';
}

Saída:

not equal?     : true
greater?       : false
less equal?    : true
greater equal? : false
Morty Proxy This is a proxified and sanitized view of the page, visit original site.