]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/static_ptr: make free operator==() a member
authorKefu Chai <tchaikov@gmail.com>
Tue, 26 Jul 2022 00:13:22 +0000 (08:13 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 30 Jul 2022 05:02:16 +0000 (13:02 +0800)
since operator==() is now considered commutative in C++20, we can
make it a member function.

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

index 2091c6cf4d609a02048f2a16a4e69cff94e87f25..31df4cf0a3ca58eb3cd501be52a55f01054ac368 100644 (file)
@@ -166,6 +166,11 @@ public:
     return *this;
   }
 
+
+  bool operator ==(std::nullptr_t) const {
+    return !operate;
+  }
+
   // In-place construction!
   //
   // This is basically what you want, and I didn't include value
@@ -325,15 +330,6 @@ static_ptr<U, Z> resize_pointer_cast(static_ptr<T, S>&& p) {
   return r;
 }
 
-template<typename Base, std::size_t Size>
-bool operator ==(const static_ptr<Base, Size>& s, std::nullptr_t) {
-  return !s;
-}
-template<typename Base, std::size_t Size>
-bool operator ==(static_ptr<Base, Size>& s, std::nullptr_t) {
-  return !s;
-}
-
 // Since `make_unique` and `make_shared` exist, we should follow their
 // lead.
 //