How do I get operators >
, >=
, <=
, and !=
from ==
and <
?
standard header <utility>
defines a namespace std::rel_ops that defines the above operators in terms of operators ==
and <
, but I don't know how to use it (coax my code into using such definitions for:
std::sort(v.begin(), v.end(), std::greater<MyType>);
where I have defined non-member operators:
bool operator < (const MyType & lhs, const MyType & rhs);
bool operator == (const MyType & lhs, const MyType & rhs);
If I #include <utility>
and specify using namespace std::rel_ops;
the compiler still complains that binary '>' : no operator found which takes a left-hand operand of type 'MyType'
..