فهرست منبع

is_equality_comparable: detect C-style arrays directly

Michele Caini 3 سال پیش
والد
کامیت
423f7a555d
2فایلهای تغییر یافته به همراه5 افزوده شده و 0 حذف شده
  1. 4 0
      src/entt/core/type_traits.hpp
  2. 1 0
      test/entt/core/type_traits.cpp

+ 4 - 0
src/entt/core/type_traits.hpp

@@ -658,6 +658,10 @@ template<typename Type>
 struct is_equality_comparable<Type, std::void_t<decltype(std::declval<Type>() == std::declval<Type>())>>
     : std::bool_constant<internal::maybe_equality_comparable<Type>(choice<2>)> {};
 
+/*! @copydoc is_equality_comparable */
+template<typename Type, auto N>
+struct is_equality_comparable<Type[N]>: std::false_type {};
+
 /**
  * @brief Helper variable template.
  * @tparam Type The type to test.

+ 1 - 0
test/entt/core/type_traits.cpp

@@ -183,6 +183,7 @@ TEST(IsEqualityComparable, Functionalities) {
     static_assert(entt::is_equality_comparable_v<std::vector<not_comparable>::iterator>);
     static_assert(entt::is_equality_comparable_v<nlohmann_json_like>);
 
+    static_assert(!entt::is_equality_comparable_v<int[3u]>);
     static_assert(!entt::is_equality_comparable_v<not_comparable>);
     static_assert(!entt::is_equality_comparable_v<const not_comparable>);
     static_assert(!entt::is_equality_comparable_v<std::vector<not_comparable>>);