diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index e7c959924..06de1993c 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -9,6 +9,7 @@ #include #include #include "../config/config.h" +#include "../core/type_traits.hpp" namespace entt { @@ -137,9 +138,43 @@ struct meta_node<> { }; +template +static bool compare(const void *lhs, const void *rhs) { + if constexpr(!std::is_function_v && is_equality_comparable_v) { + return *static_cast(lhs) == *static_cast(rhs); + } else { + return lhs == rhs; + } +} + + template struct meta_node { - inline static meta_type_node * resolve() ENTT_NOEXCEPT; + static meta_type_node * resolve() ENTT_NOEXCEPT { + static meta_type_node node{ + {}, + nullptr, + nullptr, + std::is_void_v, + std::is_integral_v, + std::is_floating_point_v, + std::is_array_v, + std::is_enum_v, + std::is_union_v, + std::is_class_v, + std::is_pointer_v, + std::is_pointer_v && std::is_function_v>, + std::is_member_object_pointer_v, + std::is_member_function_pointer_v, + std::extent_v, + &compare, // workaround for an issue with VS2017 + []() ENTT_NOEXCEPT -> meta_type_node * { + return meta_node>>::resolve(); + } + }; + + return &node; + } }; @@ -1758,66 +1793,6 @@ inline meta_type meta_func::arg(size_type index) const ENTT_NOEXCEPT { } -/** - * @cond TURN_OFF_DOXYGEN - * Internal details not to be documented. - */ - - -namespace internal { - - -template && !std::is_function_v>> -static auto compare(int, const void *lhs, const void *rhs) --> decltype(std::declval() == std::declval(), bool{}) { - return *static_cast(lhs) == *static_cast(rhs); -} - -template -static bool compare(char, const void *lhs, const void *rhs) { - return lhs == rhs; -} - - -template -inline meta_type_node * meta_node::resolve() ENTT_NOEXCEPT { - static meta_type_node node{ - {}, - nullptr, - nullptr, - std::is_void_v, - std::is_integral_v, - std::is_floating_point_v, - std::is_array_v, - std::is_enum_v, - std::is_union_v, - std::is_class_v, - std::is_pointer_v, - std::is_pointer_v && std::is_function_v>, - std::is_member_object_pointer_v, - std::is_member_function_pointer_v, - std::extent_v, - [](const void *lhs, const void *rhs) { - return compare(0, lhs, rhs); - }, - []() ENTT_NOEXCEPT -> meta_type_node * { - return internal::meta_info>::resolve(); - } - }; - - return &node; -} - - -} - - -/** - * Internal details not to be documented. - * @endcond TURN_OFF_DOXYGEN - */ - - }