]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include: drop WRITE_{EQ,CMP}_OPERATORS_1()
authorKefu Chai <tchaikov@gmail.com>
Wed, 3 Aug 2022 02:38:58 +0000 (10:38 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 4 Aug 2022 13:33:51 +0000 (21:33 +0800)
the default-generated comparison operators can fulfill our needs.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/include/cmp.h
src/include/types.h

index 79372fde542f4107dfedebd82e8c1ead5a1969a9..6dd6a7b218b7d5577350d41336a7d11af8d469df 100644 (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;                                   \
index 6737f3dc91814731ddfff36c6fd62e2f93efc0a1..e62ef446cb1b236daf5052d9cdb48cf598433e26 100644 (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 {