mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 03:57:35 +00:00
Everywhere: Remove redundant inequality comparison operators
C++20 can automatically synthesize `operator!=` from `operator==`, so there is no point in writing such functions by hand if all they do is call through to `operator==`. This fixes a compile error with compilers that implement P2468 (Clang 16 currently). This paper restores the C++17 behavior that if both `T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators makes the rewriting possible again. See https://reviews.llvm.org/D134529#3853062
This commit is contained in:
parent
4e406b0730
commit
4296425bd8
40 changed files with 1 additions and 180 deletions
|
@ -260,29 +260,20 @@ public:
|
|||
ALWAYS_INLINE operator bool() { return !is_null(); }
|
||||
|
||||
bool operator==(std::nullptr_t) const { return is_null(); }
|
||||
bool operator!=(std::nullptr_t) const { return !is_null(); }
|
||||
|
||||
bool operator==(RefPtr const& other) const { return as_ptr() == other.as_ptr(); }
|
||||
bool operator!=(RefPtr const& other) const { return as_ptr() != other.as_ptr(); }
|
||||
|
||||
bool operator==(RefPtr& other) { return as_ptr() == other.as_ptr(); }
|
||||
bool operator!=(RefPtr& other) { return as_ptr() != other.as_ptr(); }
|
||||
|
||||
template<typename U>
|
||||
bool operator==(NonnullRefPtr<U> const& other) const { return as_ptr() == other.m_ptr; }
|
||||
template<typename U>
|
||||
bool operator!=(NonnullRefPtr<U> const& other) const { return as_ptr() != other.m_ptr; }
|
||||
|
||||
template<typename U>
|
||||
bool operator==(NonnullRefPtr<U>& other) { return as_ptr() == other.m_ptr; }
|
||||
template<typename U>
|
||||
bool operator!=(NonnullRefPtr<U>& other) { return as_ptr() != other.m_ptr; }
|
||||
|
||||
bool operator==(T const* other) const { return as_ptr() == other; }
|
||||
bool operator!=(T const* other) const { return as_ptr() != other; }
|
||||
|
||||
bool operator==(T* other) { return as_ptr() == other; }
|
||||
bool operator!=(T* other) { return as_ptr() != other; }
|
||||
|
||||
ALWAYS_INLINE bool is_null() const { return !m_ptr; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue