From 86e558b6cea68b2507b74ecde3b9fca0e4ed32d7 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 19 Dec 2024 11:38:34 +0100 Subject: [PATCH] type_traits: refine is_iterator and is_equality_comparable --- src/entt/core/type_traits.hpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index f6a9ea9de..8a56bdc8f 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -675,22 +675,9 @@ inline constexpr bool is_complete_v = is_complete::value; template struct is_iterator: std::false_type {}; -/*! @cond TURN_OFF_DOXYGEN */ -namespace internal { - -template -struct has_iterator_category: std::false_type {}; - -template -struct has_iterator_category::iterator_category>>: std::true_type {}; - -} // namespace internal -/*! @endcond */ - /*! @copydoc is_iterator */ template -struct is_iterator>>>> - : internal::has_iterator_category {}; +struct is_iterator::iterator_category>>: std::true_type {}; /** * @brief Helper variable template. @@ -749,6 +736,12 @@ struct has_value_type: std::false_type {}; template struct has_value_type>: std::true_type {}; +template +struct has_void_element_type: std::false_type {}; + +template +struct has_void_element_type::element_type>: std::true_type {}; + template [[nodiscard]] constexpr bool dispatch_is_equality_comparable(); @@ -770,7 +763,7 @@ template template [[nodiscard]] constexpr bool dispatch_is_equality_comparable() { // NOLINTBEGIN(modernize-use-transparent-functors) - if constexpr(std::is_array_v) { + if constexpr(std::is_array_v || has_void_element_type::value) { return false; } else if constexpr(!is_iterator_v && has_value_type::value) { if constexpr(std::is_same_v || dispatch_is_equality_comparable()) {