クラスのすべての関係演算子を、既にそれらの演算子を持つメンバーに基づいて作成したい場合、これよりも簡単な方法はありませんか?
struct foo {
some_class mem; //some_class already has all the relational operators
//other members
}
//is there really no shorter way than to type these 6 functions?
bool operator==(const foo &lhs, const foo &rhs) { return lhs.mem == rhs.mem; }
bool operator!=(const foo &lhs, const foo &rhs) { return lhs.mem != rhs.mem; }
bool operator<(const foo &lhs, const foo &rhs) { return lhs.mem < rhs.mem; }
bool operator>(const foo &lhs, const foo &rhs) { return lhs.mem > rhs.mem; }
bool operator<=(const foo &lhs, const foo &rhs) { return lhs.mem <= rhs.mem; }
bool operator>=(const foo &lhs, const foo &rhs) { return lhs.mem >= rhs.mem; }