Xuwei Fu created ARROW-17408: -------------------------------- Summary: C++20 compile arrow get `operator==` ambiguous Key: ARROW-17408 URL: https://issues.apache.org/jira/browse/ARROW-17408 Project: Apache Arrow Issue Type: Bug Components: C++ Affects Versions: 9.0.0 Reporter: Xuwei Fu
When compiling arrow-9.0.0 in C++20, I got: ``` In file included from ../arrow/cpp/src/arrow/ipc/dictionary.cc:32: ../arrow/cpp/src/arrow/record_batch.h:266:21: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const Result<std::shared_ptr<RecordBatch>>' and 'const Result<std::shared_ptr<RecordBatch>>') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator] return batch_ == other.batch_; ~~~~~~ ^ ~~~~~~~~~~~~ ../arrow/cpp/src/arrow/util/compare.h:54:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed bool operator==(const T& other) const \{ return cast().Equals(other); } ^ In file included from ../arrow/cpp/src/arrow/ipc/dictionary.cc:18: In file included from ../arrow/cpp/src/arrow/ipc/dictionary.h:27: ../arrow/cpp/src/arrow/result.h:278:20: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const arrow::Status' and 'const arrow::Status') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator] return status_ == other.status_; ~~~~~~~ ^ ~~~~~~~~~~~~~ ../arrow/cpp/src/arrow/util/compare.h:54:57: note: in instantiation of member function 'arrow::Result<std::shared_ptr<arrow::RecordBatch>>::Equals' requested here bool operator==(const T& other) const \{ return cast().Equals(other); } ^ ../arrow/cpp/src/arrow/record_batch.h:266:21: note: in instantiation of member function 'arrow::util::EqualityComparable<arrow::Result<std::shared_ptr<arrow::RecordBatch>>>::operator==' requested here return batch_ == other.batch_; ^ ../arrow/cpp/src/arrow/util/compare.h:54:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed bool operator==(const T& other) const \{ return cast().Equals(other); } ^ 2 warnings generated. In file included from ../arrow/cpp/src/arrow/ipc/message.cc:33: In file included from ../arrow/cpp/src/arrow/ipc/reader.h:32: ../arrow/cpp/src/arrow/record_batch.h:266:21: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const Result<std::shared_ptr<RecordBatch>>' and 'const Result<std::shared_ptr<RecordBatch>>') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator] return batch_ == other.batch_; ~~~~~~ ^ ~~~~~~~~~~~~ ../arrow/cpp/src/arrow/util/compare.h:54:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed bool operator==(const T& other) const \{ return cast().Equals(other); } ^ In file included from ../arrow/cpp/src/arrow/ipc/message.cc:18: In file included from ../arrow/cpp/src/arrow/ipc/message.h:30: ../arrow/cpp/src/arrow/result.h:278:20: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const arrow::Status' and 'const arrow::Status') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator] return status_ == other.status_; ~~~~~~~ ^ ~~~~~~~~~~~~~ ../arrow/cpp/src/arrow/util/compare.h:54:57: note: in instantiation of member function 'arrow::Result<std::shared_ptr<arrow::RecordBatch>>::Equals' requested here bool operator==(const T& other) const \{ return cast().Equals(other); } ^ ../arrow/cpp/src/arrow/record_batch.h:266:21: note: in instantiation of member function 'arrow::util::EqualityComparable<arrow::Result<std::shared_ptr<arrow::RecordBatch>>>::operator==' requested here return batch_ == other.batch_; ^ ../arrow/cpp/src/arrow/util/compare.h:54:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed bool operator==(const T& other) const \{ return cast().Equals(other); } ``` Generate or hand written `operator==` for `Result` maybe fixing this problem -- This message was sent by Atlassian Jira (v8.20.10#820010)