From f987a841d779dacb0fb9f945d0d32000be9738ac Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 26 Jul 2022 08:13:22 +0800 Subject: [PATCH] common/static_ptr: make free operator==() a member since operator==() is now considered commutative in C++20, we can make it a member function. Signed-off-by: Kefu Chai --- src/common/static_ptr.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/common/static_ptr.h b/src/common/static_ptr.h index 2091c6cf4d609..31df4cf0a3ca5 100644 --- a/src/common/static_ptr.h +++ b/src/common/static_ptr.h @@ -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 resize_pointer_cast(static_ptr&& p) { return r; } -template -bool operator ==(const static_ptr& s, std::nullptr_t) { - return !s; -} -template -bool operator ==(static_ptr& s, std::nullptr_t) { - return !s; -} - // Since `make_unique` and `make_shared` exist, we should follow their // lead. // -- 2.39.5