Browse Source

meta: also please toolset v141 :)

Michele Caini 4 years ago
parent
commit
fee48ab04c
2 changed files with 6 additions and 1 deletions
  1. 1 0
      src/entt/meta/meta.hpp
  2. 5 1
      src/entt/meta/node.hpp

+ 1 - 0
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;
     }

+ 5 - 1
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<Type> || std::is_enum_v<Type>) {
+        if constexpr(std::is_arithmetic_v<Type>) {
             return +[](const any &storage, const double *value) {
                 return value ? static_cast<double>(any_cast<Type &>(const_cast<any &>(storage)) = static_cast<Type>(*value)) : static_cast<double>(any_cast<const Type &>(storage));
             };
+        } else if constexpr(std::is_enum_v<Type>) {
+            return +[](const any &storage, const double *value) {
+                return value ? static_cast<double>(any_cast<Type &>(const_cast<any &>(storage)) = Type{static_cast<std::underlying_type_t<Type>>(*value)}) : static_cast<double>(any_cast<const Type &>(storage));
+            };
         } else {
             return nullptr;
         }