Browse Source

meta: cleanup internal::try_convert

skypjack 6 months ago
parent
commit
d8aa90234a
2 changed files with 5 additions and 5 deletions
  1. 2 2
      src/entt/meta/meta.hpp
  2. 3 3
      src/entt/meta/node.hpp

+ 2 - 2
src/entt/meta/meta.hpp

@@ -1335,7 +1335,7 @@ public:
      * @return True if the conversion is allowed, false otherwise.
      */
     [[nodiscard]] bool can_convert(const meta_type &other) const noexcept {
-        return (internal::try_convert(internal::meta_context::from(*ctx), node, other.info(), other.is_arithmetic() || other.is_enum(), nullptr, [](const void *, auto &&...args) { return ((static_cast<void>(args), 1) + ... + 0u); }) != 0u);
+        return (internal::try_convert(internal::meta_context::from(*ctx), node, other.info().hash(), other.is_arithmetic() || other.is_enum(), nullptr, [](const void *, auto &&...args) { return ((static_cast<void>(args), 1) + ... + 0u); }) != 0u);
     }
 
     /**
@@ -1571,7 +1571,7 @@ bool meta_any::set(const id_type id, Type &&value) {
 }
 
 [[nodiscard]] inline meta_any meta_any::allow_cast(const meta_type &type) const {
-    return internal::try_convert(internal::meta_context::from(*ctx), node, type.info(), type.is_arithmetic() || type.is_enum(), storage.data(), [this, &type]([[maybe_unused]] const void *instance, [[maybe_unused]] auto &&...args) {
+    return internal::try_convert(internal::meta_context::from(*ctx), node, type.info().hash(), type.is_arithmetic() || type.is_enum(), storage.data(), [this, &type]([[maybe_unused]] const void *instance, [[maybe_unused]] auto &&...args) {
         if constexpr((std::is_same_v<std::remove_const_t<std::remove_reference_t<decltype(args)>>, internal::meta_type_node> || ...)) {
             return (args.from_void(*ctx, nullptr, instance), ...);
         } else if constexpr((std::is_same_v<std::remove_const_t<std::remove_reference_t<decltype(args)>>, internal::meta_conv_node> || ...)) {

+ 3 - 3
src/entt/meta/node.hpp

@@ -214,14 +214,14 @@ template<typename... Args>
 }
 
 template<typename Func>
-[[nodiscard]] inline auto try_convert(const meta_context &context, const meta_type_node &from, const type_info &to, const bool arithmetic_or_enum, const void *instance, Func func) {
-    if(from.info && *from.info == to) {
+[[nodiscard]] inline auto try_convert(const meta_context &context, const meta_type_node &from, const id_type to, const bool arithmetic_or_enum, const void *instance, Func func) {
+    if(from.info && from.info->hash() == to) {
         return func(instance, from);
     }
 
     if(from.details) {
         for(auto &&elem: from.details->conv) {
-            if(elem.type == to.hash()) {
+            if(elem.type == to) {
                 return func(instance, elem);
             }
         }