Просмотр исходного кода

meta: use a shared_pointer to void for meta properties

Michele Caini 3 лет назад
Родитель
Сommit
a30cecdf36
3 измененных файлов с 4 добавлено и 3 удалено
  1. 2 1
      src/entt/meta/factory.hpp
  2. 1 1
      src/entt/meta/meta.hpp
  3. 1 1
      src/entt/meta/node.hpp

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

@@ -3,6 +3,7 @@
 
 #include <cstddef>
 #include <functional>
+#include <memory>
 #include <tuple>
 #include <type_traits>
 #include <utility>
@@ -82,7 +83,7 @@ public:
 
         node->details->prop[key] = internal::meta_prop_node{
             &internal::resolve<std::decay_t<Value>>...,
-            std::forward<Value>(value)...};
+            std::make_shared<std::decay_t<Value>>(std::forward<Value>(value))...};
 
         return *this;
     }

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

@@ -669,7 +669,7 @@ struct meta_prop {
      * @return A wrapper containing the value stored with the property.
      */
     [[nodiscard]] meta_any value() const {
-        return (node && node->type) ? node->type()->from_void(nullptr, node->value.data()) : meta_any{};
+        return (node && node->type) ? node->type()->from_void(nullptr, node->value.get()) : meta_any{};
     }
 
     /**

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

@@ -49,7 +49,7 @@ struct meta_type_node;
 
 struct meta_prop_node {
     meta_type_node *(*type)() noexcept {};
-    basic_any<0u> value{};
+    std::shared_ptr<void> value{};
 };
 
 struct meta_base_node {