[dawn/common] Use C++20 default equation comparison when possible

Bug: 343500108
Change-Id: I45a41ea9b854cb96d7a0c4b6213140d42a2c5c30
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/241414
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/common/BitSetRangeIterator.h b/src/dawn/common/BitSetRangeIterator.h
index d44ad3c..4a83a7d 100644
--- a/src/dawn/common/BitSetRangeIterator.h
+++ b/src/dawn/common/BitSetRangeIterator.h
@@ -54,8 +54,7 @@
         explicit Iterator(const std::bitset<N>& bits, uint32_t offset = 0, uint32_t size = 0);
         Iterator& operator++();
 
-        bool operator==(const Iterator& other) const;
-        bool operator!=(const Iterator& other) const;
+        bool operator==(const Iterator& other) const = default;
 
         // Returns a pair of offset and size of the current range
         std::pair<T, size_t> operator*() const {
@@ -111,16 +110,6 @@
 }
 
 template <size_t N, typename T>
-bool BitSetRangeIterator<N, T>::Iterator::operator==(const Iterator& other) const {
-    return mOffset == other.mOffset && mSize == other.mSize && mBits == other.mBits;
-}
-
-template <size_t N, typename T>
-bool BitSetRangeIterator<N, T>::Iterator::operator!=(const Iterator& other) const {
-    return !(*this == other);
-}
-
-template <size_t N, typename T>
 size_t BitSetRangeIterator<N, T>::Iterator::ScanForwardAndShiftBits() {
     if (mBits.none()) {
         return N;  // Or some other indicator that there are no bits.
diff --git a/src/dawn/common/Range.h b/src/dawn/common/Range.h
index 8ab2cf4..f4fd777 100644
--- a/src/dawn/common/Range.h
+++ b/src/dawn/common/Range.h
@@ -51,8 +51,7 @@
     class Iterator final {
       public:
         explicit Iterator(Integer value) : mValue(value) {}
-        bool operator==(const Iterator& other) const { return other.mValue == mValue; }
-        bool operator!=(const Iterator& other) const { return !(*this == other); }
+        bool operator==(const Iterator& other) const = default;
         Iterator& operator++() {
             mValue++;
             return *this;
diff --git a/src/dawn/common/RefBase.h b/src/dawn/common/RefBase.h
index 7f45644..e341006 100644
--- a/src/dawn/common/RefBase.h
+++ b/src/dawn/common/RefBase.h
@@ -124,8 +124,7 @@
     bool operator==(const T& other) const { return mValue == other; }
     bool operator!=(const T& other) const { return mValue != other; }
 
-    bool operator==(const RefBase<T, Traits>& other) const { return mValue == other.mValue; }
-    bool operator!=(const RefBase<T, Traits>& other) const { return mValue != other.mValue; }
+    bool operator==(const RefBase<T, Traits>& other) const = default;
 
     const T operator->() const { return mValue; }
     T operator->() { return mValue; }
diff --git a/src/dawn/common/SerialStorage.h b/src/dawn/common/SerialStorage.h
index c6d75cf..244d6bc 100644
--- a/src/dawn/common/SerialStorage.h
+++ b/src/dawn/common/SerialStorage.h
@@ -54,8 +54,7 @@
         explicit Iterator(StorageIterator start);
         Iterator& operator++();
 
-        bool operator==(const Iterator& other) const;
-        bool operator!=(const Iterator& other) const;
+        bool operator==(const Iterator& other) const = default;
         Value& operator*() const;
 
       private:
@@ -71,8 +70,7 @@
         explicit ConstIterator(ConstStorageIterator start);
         ConstIterator& operator++();
 
-        bool operator==(const ConstIterator& other) const;
-        bool operator!=(const ConstIterator& other) const;
+        bool operator==(const ConstIterator& other) const = default;
         const Value& operator*() const;
 
       private:
@@ -246,18 +244,6 @@
 }
 
 template <typename Derived>
-bool SerialStorage<Derived>::Iterator::operator==(
-    const typename SerialStorage<Derived>::Iterator& other) const {
-    return other.mStorageIterator == mStorageIterator && other.mSerialIterator == mSerialIterator;
-}
-
-template <typename Derived>
-bool SerialStorage<Derived>::Iterator::operator!=(
-    const typename SerialStorage<Derived>::Iterator& other) const {
-    return !(*this == other);
-}
-
-template <typename Derived>
 typename SerialStorage<Derived>::Value& SerialStorage<Derived>::Iterator::operator*() const {
     if (mSerialIterator == nullptr) {
         return *mStorageIterator->second.begin();
@@ -311,18 +297,6 @@
 }
 
 template <typename Derived>
-bool SerialStorage<Derived>::ConstIterator::operator==(
-    const typename SerialStorage<Derived>::ConstIterator& other) const {
-    return other.mStorageIterator == mStorageIterator && other.mSerialIterator == mSerialIterator;
-}
-
-template <typename Derived>
-bool SerialStorage<Derived>::ConstIterator::operator!=(
-    const typename SerialStorage<Derived>::ConstIterator& other) const {
-    return !(*this == other);
-}
-
-template <typename Derived>
 const typename SerialStorage<Derived>::Value& SerialStorage<Derived>::ConstIterator::operator*()
     const {
     if (mSerialIterator == nullptr) {
diff --git a/src/dawn/common/WeakRef.h b/src/dawn/common/WeakRef.h
index 548b85b..c5adc1b 100644
--- a/src/dawn/common/WeakRef.h
+++ b/src/dawn/common/WeakRef.h
@@ -84,8 +84,7 @@
     WeakRef(WeakRefSupport<T>* support) : mData(support->mData) {}
 
     // Comparison operators.
-    bool operator==(const WeakRef<T>& other) const { return mData == other.mData; }
-    bool operator!=(const WeakRef<T>& other) const { return mData != other.mData; }
+    bool operator==(const WeakRef<T>& other) const = default;
 
     // Promotes a WeakRef to a Ref. Access to the raw pointer is not allowed because a raw pointer
     // could become invalid after being retrieved.
diff --git a/src/dawn/common/ityp_bitset.h b/src/dawn/common/ityp_bitset.h
index 5371bc6..74bdcfb 100644
--- a/src/dawn/common/ityp_bitset.h
+++ b/src/dawn/common/ityp_bitset.h
@@ -50,8 +50,7 @@
         : mBits(static_cast<uint64_t>(bits.to_ullong())) {}
     Iterator64& operator++();
 
-    bool operator==(const Iterator64& other) const { return mBits == other.mBits; }
-    bool operator!=(const Iterator64& other) const { return !(*this == other); }
+    bool operator==(const Iterator64& other) const = default;
 
     Index operator*() const;
 
diff --git a/src/dawn/common/vulkan_platform.h b/src/dawn/common/vulkan_platform.h
index 99a2f9d..fa59376 100644
--- a/src/dawn/common/vulkan_platform.h
+++ b/src/dawn/common/vulkan_platform.h
@@ -95,8 +95,7 @@
     VkHandle& operator=(const VkHandle<Tag, HandleType>&) = default;
 
     // Comparisons between handles
-    bool operator==(VkHandle<Tag, HandleType> other) const { return mHandle == other.mHandle; }
-    bool operator!=(VkHandle<Tag, HandleType> other) const { return mHandle != other.mHandle; }
+    bool operator==(const VkHandle<Tag, HandleType>& other) const = default;
 
     // Comparisons between handles and VK_NULL_HANDLE
     bool operator==(std::nullptr_t) const { return mHandle == 0; }