From Cppreference
|
|
|
|
|
template< class T > bool operator!=( const T& lhs, const T& rhs );
|
|
|
|
|
Given a user-defined operator== for objects of type T, implements the usual semantics of operator!=.
[edit] Parameters
lhs
|
-
|
left-hand argument
|
rhs
|
-
|
right-hand argument
|
[edit] Return value
Returns false if lhs==rhs returns true, true otherwise.
[edit] Equivalent function
namespace rel_ops {
template< class T >
bool operator!=( const T& lhs, const T& rhs ) {
return !(lhs == rhs);
}
}
|
[edit] Example
#include <iostream>
#include <utility>
struct Foo {
int 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;
if(f1 != f2)
std::cout << "Not equal\n";
}
Output:
[edit] See also
|
|
automatically generated operator> based on user-defined operator< (function template)
|
|
|
automatically generated operator<= based on user-defined operator< (function template)
|
|
|
automatically generated operator<= based on user-defined operator< (function template)
|