diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 37024ef7f..0b081eca3 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -1511,6 +1511,7 @@ bool meta_any::set(const id_type id, Type &&value) { // exploits the fact that arithmetic types and enums are also default constructible auto other = type.construct(); const double value = node->conversion_helper(storage, nullptr); + ENTT_ASSERT(other.node->conversion_helper, "Conversion helper not found"); other.node->conversion_helper(other.storage, &value); return other; } diff --git a/src/entt/meta/node.hpp b/src/entt/meta/node.hpp index 64d702e1e..99e011a63 100644 --- a/src/entt/meta/node.hpp +++ b/src/entt/meta/node.hpp @@ -150,10 +150,14 @@ class ENTT_API meta_node { } [[nodiscard]] static decltype(meta_type_node::conversion_helper) meta_conversion_helper() ENTT_NOEXCEPT { - if constexpr(std::is_arithmetic_v || std::is_enum_v) { + if constexpr(std::is_arithmetic_v) { return +[](const any &storage, const double *value) { return value ? static_cast(any_cast(const_cast(storage)) = static_cast(*value)) : static_cast(any_cast(storage)); }; + } else if constexpr(std::is_enum_v) { + return +[](const any &storage, const double *value) { + return value ? static_cast(any_cast(const_cast(storage)) = Type{static_cast>(*value)}) : static_cast(any_cast(storage)); + }; } else { return nullptr; }