]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/fifo: use friend instead of member operators
authorKefu Chai <tchaikov@gmail.com>
Mon, 14 Mar 2022 15:35:13 +0000 (23:35 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 17 Mar 2022 14:00:36 +0000 (22:00 +0800)
to address following error when compiling with C++20 standard:

../src/rgw/cls_fifo_legacy.cc:2217:22: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'rados::cls::fifo::journal_entry' and 'rados::cls::fifo::journal_entry') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
            !(jiter->second == e)) {
              ~~~~~~~~~~~~~ ^  ~
../src/cls/fifo/cls_fifo_types.h:148:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
  bool operator ==(const journal_entry& e) {
       ^

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/cls/fifo/cls_fifo_types.h

index 8a471828b7a5ac139b8876cebdc53d2aaa5822f0..13f479fe64ab959f831a60ac5778c74e2b2d3295 100644 (file)
@@ -145,10 +145,10 @@ struct journal_entry {
   }
   void dump(ceph::Formatter* f) const;
 
-  bool operator ==(const journal_entry& e) {
-    return (op == e.op &&
-           part_num == e.part_num &&
-           part_tag == e.part_tag);
+  friend bool operator ==(const journal_entry& lhs, const journal_entry& rhs) {
+    return (lhs.op == rhs.op &&
+           lhs.part_num == rhs.part_num &&
+           lhs.part_tag == rhs.part_tag);
   }
 };
 WRITE_CLASS_ENCODER(journal_entry)