Michele Caini 8 лет назад
Родитель
Сommit
871f090ca0
2 измененных файлов с 8 добавлено и 1 удалено
  1. 1 1
      src/entt/entity/registry.hpp
  2. 7 0
      test/entt/entity/registry.cpp

+ 1 - 1
src/entt/entity/registry.hpp

@@ -355,7 +355,7 @@ public:
     entity_type create(Component&&... components) noexcept {
         using accumulator_type = int[];
         const auto entity = create();
-        accumulator_type accumulator = { 0, (ensure<Component>().construct(*this, entity, std::forward<Component>(components)), 0)... };
+        accumulator_type accumulator = { 0, (ensure<std::decay_t<Component>>().construct(*this, entity, std::forward<Component>(components)), 0)... };
         (void)accumulator;
         return entity;
     }

+ 7 - 0
test/entt/entity/registry.cpp

@@ -401,3 +401,10 @@ TEST(DefaultRegistry, ComponentsWithTypesFromStandardTemplateLibrary) {
     registry.assign<std::unordered_set<int>>(entity).insert(42);
     registry.destroy(entity);
 }
+
+TEST(DefaultRegistry, ConstructWithComponents) {
+    // it should compile, that's all
+    entt::DefaultRegistry registry;
+    const auto value = 0;
+    registry.create(value);
+}