
Category: utilities  Component type: function 
template <class T> bool operator!=(const T& x, const T& y); template <class T> bool operator>(const T& x, const T& y); template <class T> bool operator<=(const T& x, const T& y); template <class T> bool operator>=(const T& x, const T& y);
These four templates use operator== and operator< to define the other four relational operators. They exist purely for the sake of convenience: they make it possible to write algorithms in terms of the operators !=, >, <=, and >=, without requiring that those operators be explicitly defined for every type.
As specified in the Equality Comparable requirements, x != y is equivalent to !(x == y). As specified in the LessThan Comparable requirements, x > y is equivalent to y < x, x >= y is equivalent to !(x < y), and x <= y is equivalent to !(y < x).
The requirement for operator> is that y < x is a valid expression for objects x and y of type T.
The requirement for operator<= is that y < x is a valid expression for objects x and y of type T.
The requirement for operator>= is that x < y is a valid expression for objects x and y of type T.
The precondition for operator>, operator<=, and operator>= is that x and y are in the domain of operator<.
template <class T> void relations(T x, T y) { if (x == y) assert(!(x != y)); else assert(x != y); if (x < y) { assert(x <= y); assert(y > x); assert(y >= x); } else if (y < x) { assert(y <= x); assert(x < y); assert(x <= y); } else { assert(x <= y); assert(x >= y); } }
Contact Us  Site Map  Trademarks  Privacy  Using this site means you accept its Terms of Use 
Copyright © 2009  2017 Silicon Graphics International. All rights reserved. 