Michele Caini 6 лет назад
Родитель
Сommit
65e270ff57
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      src/entt/entity/storage.hpp

+ 4 - 5
src/entt/entity/storage.hpp

@@ -334,7 +334,7 @@ public:
      * @brief Assigns one or more entities to a storage and constructs their
      * @brief Assigns one or more entities to a storage and constructs their
      * objects.
      * objects.
      *
      *
-     * The object type must be at least default constructible.
+     * The object type must be at least move and default insertable.
      *
      *
      * @warning
      * @warning
      * Attempting to assign an entity that already belongs to the storage
      * Attempting to assign an entity that already belongs to the storage
@@ -350,12 +350,11 @@ public:
      */
      */
     template<typename It>
     template<typename It>
     object_type * batch(It first, It last) {
     object_type * batch(It first, It last) {
-        static_assert(std::is_default_constructible_v<object_type>);
-        const auto skip = instances.size();
-        instances.insert(instances.end(), last-first, {});
+        const auto length = last - first;
+        instances.resize(instances.size() + length);
         // entity goes after component in case constructor throws
         // entity goes after component in case constructor throws
         underlying_type::batch(first, last);
         underlying_type::batch(first, last);
-        return instances.data() + skip;
+        return instances.data() + instances.size() - length;
     }
     }
 
 
     /**
     /**