From: Kefu Chai Date: Thu, 3 Mar 2022 07:30:59 +0000 (+0800) Subject: common/static_ptr: drop ambiguous operator==() X-Git-Tag: v18.0.0~366^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3d119c82792592f924ba0f896027f361067b859a;p=ceph-ci.git common/static_ptr: drop ambiguous operator==() 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' 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 --- diff --git a/src/common/static_ptr.h b/src/common/static_ptr.h index 542f1e9a67a..2091c6cf4d6 100644 --- a/src/common/static_ptr.h +++ b/src/common/static_ptr.h @@ -330,17 +330,9 @@ bool operator ==(const static_ptr& s, std::nullptr_t) { return !s; } template -bool operator ==(std::nullptr_t, const static_ptr& s) { - return !s; -} -template bool operator ==(static_ptr& s, std::nullptr_t) { return !s; } -template -bool operator ==(std::nullptr_t, static_ptr& s) { - return !s; -} // Since `make_unique` and `make_shared` exist, we should follow their // lead.