如何从and 获取运算符>, >=, <=, and ?!===<
标准标头定义了一个命名空间 std::rel_ops ,它根据运算符and<utility>定义上述运算符,但我不知道如何使用它(哄我的代码使用这样的定义:==<
std::sort(v.begin(), v.end(), std::greater<MyType>);
我在其中定义了非成员运算符:
bool operator < (const MyType & lhs, const MyType & rhs);
bool operator == (const MyType & lhs, const MyType & rhs);
如果我#include <utility>并指定using namespace std::rel_ops;编译器仍然抱怨binary '>' : no operator found which takes a left-hand operand of type 'MyType'..