cleanup
This commit is contained in:
@@ -81,9 +81,9 @@ class basic_registry {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename It, typename... Comp>
|
||||
auto batch(basic_registry ®istry, It first, It last, const Comp &... value) {
|
||||
auto it = storage<Entity, Component>::batch(first, last, value...);
|
||||
template<typename It, typename... Args>
|
||||
auto batch(basic_registry ®istry, It first, It last, Args &&... args) {
|
||||
auto it = storage<Entity, Component>::batch(first, last, std::forward<Args>(args)...);
|
||||
|
||||
if(!construction.empty()) {
|
||||
std::for_each(first, last, [this, ®istry, it](const auto entt) mutable {
|
||||
|
||||
@@ -333,9 +333,10 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Assigns one or more entities to a storage and default constructs
|
||||
* their objects.
|
||||
* or copy constructs their objects.
|
||||
*
|
||||
* The object type must be at least move and default insertable.
|
||||
* The object type must be at least move and default insertable if no
|
||||
* arguments are provided, move and copy insertable otherwise.
|
||||
*
|
||||
* @warning
|
||||
* Attempting to assign an entity that already belongs to the storage
|
||||
@@ -344,37 +345,21 @@ public:
|
||||
* storage already contains the given entity.
|
||||
*
|
||||
* @tparam It Type of forward iterator.
|
||||
* @tparam Args Types of arguments to use to construct the object.
|
||||
* @param first An iterator to the first element of the range of entities.
|
||||
* @param last An iterator past the last element of the range of entities.
|
||||
* @param args Parameters to use to construct an object for the entities.
|
||||
* @return An iterator to the list of instances just created and sorted the
|
||||
* same of the entities.
|
||||
*/
|
||||
template<typename It>
|
||||
iterator_type batch(It first, It last) {
|
||||
instances.resize(instances.size() + std::distance(first, last));
|
||||
// entity goes after component in case constructor throws
|
||||
underlying_type::batch(first, last);
|
||||
return begin();
|
||||
}
|
||||
template<typename It, typename... Args>
|
||||
iterator_type batch(It first, It last, Args &&... args) {
|
||||
if constexpr(sizeof...(Args) == 0) {
|
||||
instances.resize(instances.size() + std::distance(first, last));
|
||||
} else {
|
||||
instances.resize(instances.size() + std::distance(first, last), Type{std::forward<Args>(args)...});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assigns one or more entities to a storage and copy constructs
|
||||
* their objects.
|
||||
*
|
||||
* The object type must be at least move and copy insertable.
|
||||
*
|
||||
* @sa batch
|
||||
*
|
||||
* @tparam It Type of forward iterator.
|
||||
* @param first An iterator to the first element of the range of entities.
|
||||
* @param last An iterator past the last element of the range of entities.
|
||||
* @param value The value to initialize the new objects with.
|
||||
* @return An iterator to the list of instances just created and sorted the
|
||||
* same of the entities.
|
||||
*/
|
||||
template<typename It>
|
||||
iterator_type batch(It first, It last, const object_type &value) {
|
||||
instances.resize(instances.size() + std::distance(first, last), value);
|
||||
// entity goes after component in case constructor throws
|
||||
underlying_type::batch(first, last);
|
||||
return begin();
|
||||
|
||||
Reference in New Issue
Block a user