Browse Source

table: operator==/operator<=>

skypjack 2 months ago
parent
commit
4df87a007d
1 changed files with 12 additions and 36 deletions
  1. 12 36
      src/entt/container/table.hpp

+ 12 - 36
src/entt/container/table.hpp

@@ -85,49 +85,25 @@ public:
         return operator[](0);
         return operator[](0);
     }
     }
 
 
-    template<typename... Lhs, typename... Rhs>
-    friend constexpr std::ptrdiff_t operator-(const table_iterator<Lhs...> &, const table_iterator<Rhs...> &) noexcept;
+    template<typename... Other>
+    [[nodiscard]] constexpr std::ptrdiff_t operator-(const table_iterator<Other...> &other) const noexcept {
+        return std::get<0>(it) - std::get<0>(other.it);
+    }
 
 
-    template<typename... Lhs, typename... Rhs>
-    friend constexpr bool operator==(const table_iterator<Lhs...> &, const table_iterator<Rhs...> &) noexcept;
+    template<typename... Other>
+    [[nodiscard]] constexpr bool operator==(const table_iterator<Other...> &other) const noexcept {
+        return std::get<0>(it) == std::get<0>(other.it);
+    }
 
 
-    template<typename... Lhs, typename... Rhs>
-    friend constexpr bool operator<(const table_iterator<Lhs...> &, const table_iterator<Rhs...> &) noexcept;
+    template<typename... Other>
+    [[nodiscard]] constexpr auto operator<=>(const table_iterator<Other...> &other) const noexcept {
+        return std::get<0>(it) <=> std::get<0>(other.it);
+    }
 
 
 private:
 private:
     std::tuple<It...> it;
     std::tuple<It...> it;
 };
 };
 
 
-template<typename... Lhs, typename... Rhs>
-[[nodiscard]] constexpr std::ptrdiff_t operator-(const table_iterator<Lhs...> &lhs, const table_iterator<Rhs...> &rhs) noexcept {
-    return std::get<0>(lhs.it) - std::get<0>(rhs.it);
-}
-
-template<typename... Lhs, typename... Rhs>
-[[nodiscard]] constexpr bool operator==(const table_iterator<Lhs...> &lhs, const table_iterator<Rhs...> &rhs) noexcept {
-    return std::get<0>(lhs.it) == std::get<0>(rhs.it);
-}
-
-template<typename... Lhs, typename... Rhs>
-[[nodiscard]] constexpr bool operator<(const table_iterator<Lhs...> &lhs, const table_iterator<Rhs...> &rhs) noexcept {
-    return std::get<0>(lhs.it) < std::get<0>(rhs.it);
-}
-
-template<typename... Lhs, typename... Rhs>
-[[nodiscard]] constexpr bool operator>(const table_iterator<Lhs...> &lhs, const table_iterator<Rhs...> &rhs) noexcept {
-    return rhs < lhs;
-}
-
-template<typename... Lhs, typename... Rhs>
-[[nodiscard]] constexpr bool operator<=(const table_iterator<Lhs...> &lhs, const table_iterator<Rhs...> &rhs) noexcept {
-    return !(lhs > rhs);
-}
-
-template<typename... Lhs, typename... Rhs>
-[[nodiscard]] constexpr bool operator>=(const table_iterator<Lhs...> &lhs, const table_iterator<Rhs...> &rhs) noexcept {
-    return !(lhs < rhs);
-}
-
 } // namespace internal
 } // namespace internal
 /*! @endcond */
 /*! @endcond */