From f5c3ae2af8068d33c7f108d120266f0b06c43682 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 14 Mar 2022 23:35:13 +0800 Subject: [PATCH] cls/fifo: use friend instead of member operators 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 --- src/cls/fifo/cls_fifo_types.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cls/fifo/cls_fifo_types.h b/src/cls/fifo/cls_fifo_types.h index 8a471828b7a..13f479fe64a 100644 --- a/src/cls/fifo/cls_fifo_types.h +++ b/src/cls/fifo/cls_fifo_types.h @@ -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) -- 2.39.5