From cc9566b6df4d71ad7408d9ccf1b7e1168745ad57 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 13 Jan 2020 18:39:56 -0800 Subject: [PATCH] Add unique_fd::operator{==,!=} overloads that take a unique_fd. With C++20, any use of the existing overloads with two unique_fd arguments is likely to become ambiguous: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20200113/301880.html Newer versions of clang complain about this ambiguity. Fix the error by adding overloads that take two unique_fds. Bug: 145916209 Change-Id: I18a292827d8841b6d24f948682123ab54dc7aaca --- base/include/android-base/unique_fd.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/include/android-base/unique_fd.h b/base/include/android-base/unique_fd.h index 1605daf71..c4a0aad0f 100644 --- a/base/include/android-base/unique_fd.h +++ b/base/include/android-base/unique_fd.h @@ -116,6 +116,8 @@ class unique_fd_impl final { bool operator<(int rhs) const { return get() < rhs; } bool operator==(int rhs) const { return get() == rhs; } bool operator!=(int rhs) const { return get() != rhs; } + bool operator==(const unique_fd_impl& rhs) const { return get() == rhs.get(); } + bool operator!=(const unique_fd_impl& rhs) const { return get() != rhs.get(); } // Catch bogus error checks (i.e.: "!fd" instead of "fd != -1"). bool operator!() const = delete;