entity: cleanup

This commit is contained in:
skypjack
2026-01-19 15:48:08 +01:00
parent 77a66812d4
commit 818ddc4e3e
6 changed files with 12 additions and 24 deletions

View File

@@ -639,12 +639,10 @@ public:
* The shared pool of entities and thus its order is affected by the changes
* to each and every pool that it tracks.
*
* @tparam It Type of input 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.
*/
template<std::input_iterator It>
void sort_as(It first, It last) const {
void sort_as(std::input_iterator auto first, std::input_iterator auto last) const {
if(*this) {
descriptor->handle().sort_as(first, last);
}

View File

@@ -356,14 +356,13 @@ public:
/**
* @brief Assigns one or more entities to a storage and constructs their
* objects from a given instance.
* @tparam It Type of input iterator.
* @tparam Args Types of arguments to forward to the underlying storage.
* @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 forward to the underlying storage.
*/
template<std::input_iterator It, typename... Args>
void insert(It first, It last, Args &&...args) {
template<typename... Args>
void insert(std::input_iterator auto first, std::input_iterator auto last, Args &&...args) {
auto from = underlying_type::size();
underlying_type::insert(first, last, std::forward<Args>(args)...);

View File

@@ -537,12 +537,10 @@ public:
*
* @sa destroy
*
* @tparam It Type of input 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.
*/
template<std::input_iterator It>
void destroy(It first, It last) {
void destroy(std::input_iterator auto first, std::input_iterator auto last) {
const auto to = entities.sort_as(first, last);
const auto from = entities.cend() - static_cast<common_type::difference_type>(entities.free_list());
@@ -580,12 +578,11 @@ public:
* @sa emplace
*
* @tparam Type Type of element to create.
* @tparam It Type of input 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.
*/
template<typename Type, std::input_iterator It>
void insert(It first, It last) {
template<typename Type>
void insert(std::input_iterator auto first, std::input_iterator auto last) {
ENTT_ASSERT(std::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity");
assure<Type>().insert(std::move(first), std::move(last));
}
@@ -596,13 +593,12 @@ public:
* @sa emplace
*
* @tparam Type Type of element to create.
* @tparam It Type of input 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 An instance of the element to assign.
*/
template<typename Type, std::input_iterator It>
void insert(It first, It last, const Type &value) {
template<typename Type>
void insert(std::input_iterator auto first, std::input_iterator auto last, const Type &value) {
ENTT_ASSERT(std::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity");
assure<Type>().insert(std::move(first), std::move(last), value);
}

View File

@@ -130,15 +130,14 @@ public:
* the entities in a range.
* @tparam Type Type of elements to serialize.
* @tparam Archive Type of output archive.
* @tparam It Type of input iterator.
* @param archive A valid reference to an output archive.
* @param first An iterator to the first element of the range to serialize.
* @param last An iterator past the last element of the range to serialize.
* @param id Optional name used to map the storage within the registry.
* @return An object of this type to continue creating the snapshot.
*/
template<typename Type, typename Archive, std::input_iterator It>
const basic_snapshot &get(Archive &archive, It first, It last, const id_type id = type_hash<Type>::value()) const {
template<typename Type, typename Archive>
const basic_snapshot &get(Archive &archive, std::input_iterator auto first, std::input_iterator auto last, const id_type id = type_hash<Type>::value()) const {
static_assert(!std::is_same_v<Type, entity_type>, "Entity types not supported");
if(const auto *storage = reg->template storage<Type>(id); storage && !storage->empty()) {

View File

@@ -786,14 +786,12 @@ public:
* Attempting to assign an entity that already belongs to the sparse set
* results in undefined behavior.
*
* @tparam It Type of input 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.
* @return Iterator pointing to the first element inserted in case of
* success, the `end()` iterator otherwise.
*/
template<std::input_iterator It>
iterator push(It first, It last) {
iterator push(std::input_iterator auto first, std::input_iterator auto last) {
auto curr = end();
for(; first != last; ++first) {

View File

@@ -688,14 +688,12 @@ public:
* Attempting to assign an entity that already belongs to the storage
* results in undefined behavior.
*
* @tparam It Type of input 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 An instance of the object to construct.
* @return Iterator pointing to the first element inserted, if any.
*/
template<std::input_iterator It>
iterator insert(It first, It last, const value_type &value = {}) {
iterator insert(std::input_iterator auto first, std::input_iterator auto last, const value_type &value = {}) {
for(; first != last; ++first) {
emplace_element(*first, true, value);
}