]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/static_ptr: drop ambiguous operator==()
authorKefu Chai <tchaikov@gmail.com>
Thu, 3 Mar 2022 07:30:59 +0000 (15:30 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 30 Jul 2022 05:02:15 +0000 (13:02 +0800)
because in C++20, comparison operator is considered reversed also. so
drop the reversed operators.

otherwise we'd have following FTBFS:

../src/test/common/test_static_ptr.cc:64:20: error: use of overloaded operator '==' is ambiguous (with operand types 'static_ptr<base, sizeof(grandchild)>' and 'nullptr_t')
    EXPECT_FALSE(p == nullptr);
                 ~ ^  ~~~~~~~
../src/googletest/googletest/include/gtest/gtest.h:1984:25: note: expanded from macro 'EXPECT_FALSE'
  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
                        ^~~~~~~~~

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/common/static_ptr.h

index 542f1e9a67a4208b4dd39fd60409044608df445e..2091c6cf4d609a02048f2a16a4e69cff94e87f25 100644 (file)
@@ -330,17 +330,9 @@ bool operator ==(const static_ptr<Base, Size>& s, std::nullptr_t) {
   return !s;
 }
 template<typename Base, std::size_t Size>
-bool operator ==(std::nullptr_t, const static_ptr<Base, Size>& s) {
-  return !s;
-}
-template<typename Base, std::size_t Size>
 bool operator ==(static_ptr<Base, Size>& s, std::nullptr_t) {
   return !s;
 }
-template<typename Base, std::size_t Size>
-bool operator ==(std::nullptr_t, static_ptr<Base, Size>& s) {
-  return !s;
-}
 
 // Since `make_unique` and `make_shared` exist, we should follow their
 // lead.