include: drop WRITE_{EQ,CMP}_OPERATORS_1()

the default-generated comparison operators can fulfill our needs.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
This commit is contained in:
Kefu Chai 2022-08-03 10:38:58 +08:00
parent 4bbc8cc2d3
commit 27e38181ab
2 changed files with 10 additions and 32 deletions

View File

@ -5,28 +5,6 @@
* macros to define comparison operators for classes with small numbers of members.
*/
#define WRITE_EQ_OPERATORS_1(type, a) \
inline bool operator==(const type &l, const type &r) { \
return l.a == r.a; \
} \
inline bool operator!=(const type &l, const type &r) { \
return l.a != r.a; \
}
#define WRITE_CMP_OPERATORS_1(type, a) \
inline bool operator>(const type &l, const type &r) { \
return l.a > r.a; \
} \
inline bool operator<(const type &l, const type &r) { \
return l.a < r.a; \
} \
inline bool operator>=(const type &l, const type &r) { \
return l.a >= r.a; \
} \
inline bool operator<=(const type &l, const type &r) { \
return l.a <= r.a; \
}
#define WRITE_EQ_OPERATORS_2(type, a, b) \
inline bool operator==(const type &l, const type &r) { \
return l.a == r.a && l.b == r.b; \

View File

@ -518,10 +518,11 @@ struct shard_id_t {
using ceph::decode;
decode(id, bl);
}
bool operator==(const shard_id_t&) const = default;
auto operator<=>(const shard_id_t&) const = default;
};
WRITE_CLASS_ENCODER(shard_id_t)
WRITE_EQ_OPERATORS_1(shard_id_t, id)
WRITE_CMP_OPERATORS_1(shard_id_t, id)
std::ostream &operator<<(std::ostream &lhs, const shard_id_t &rhs);
#if defined(__sun) || defined(_AIX) || defined(__APPLE__) || \
@ -540,15 +541,16 @@ struct errorcode32_t {
errorcode32_t() : code(0) {}
// cppcheck-suppress noExplicitConstructor
errorcode32_t(int32_t i) : code(i) {}
explicit errorcode32_t(int32_t i) : code(i) {}
operator int() const { return code; }
int* operator&() { return &code; }
int operator==(int i) { return code == i; }
int operator>(int i) { return code > i; }
int operator>=(int i) { return code >= i; }
int operator<(int i) { return code < i; }
int operator<=(int i) { return code <= i; }
errorcode32_t& operator=(int32_t i) {
code = i;
return *this;
}
bool operator==(const errorcode32_t&) const = default;
auto operator<=>(const errorcode32_t&) const = default;
void encode(ceph::buffer::list &bl) const {
using ceph::encode;
@ -562,8 +564,6 @@ struct errorcode32_t {
}
};
WRITE_CLASS_ENCODER(errorcode32_t)
WRITE_EQ_OPERATORS_1(errorcode32_t, code)
WRITE_CMP_OPERATORS_1(errorcode32_t, code)
template <uint8_t S>
struct sha_digest_t {