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

meta: make default_constructor forward the context to the returned element

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

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

@@ -193,7 +193,12 @@ template<typename Type>
         &resolve<std::remove_cv_t<std::remove_pointer_t<Type>>>};
 
     if constexpr(std::is_default_constructible_v<Type>) {
-        node.default_constructor = +[](const meta_ctx &ctx_TODO) { return meta_any{std::in_place_type<Type>}; };
+        node.default_constructor = +[](const meta_ctx &ctx) {
+            // TODO it would be great if we had value and context construction support for meta_any
+            meta_any elem{ctx};
+            elem.emplace<Type>();
+            return elem;
+        };
     }
 
     if constexpr(std::is_arithmetic_v<Type>) {