From 818ddc4e3ed0b6037e6b74d57669402fcdab9d77 Mon Sep 17 00:00:00 2001 From: skypjack Date: Mon, 19 Jan 2026 15:48:08 +0100 Subject: [PATCH] entity: cleanup --- src/entt/entity/group.hpp | 4 +--- src/entt/entity/mixin.hpp | 5 ++--- src/entt/entity/registry.hpp | 14 +++++--------- src/entt/entity/snapshot.hpp | 5 ++--- src/entt/entity/sparse_set.hpp | 4 +--- src/entt/entity/storage.hpp | 4 +--- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 319000f67..ee08c268f 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -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 - 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); } diff --git a/src/entt/entity/mixin.hpp b/src/entt/entity/mixin.hpp index baa0a40a9..e7361331d 100644 --- a/src/entt/entity/mixin.hpp +++ b/src/entt/entity/mixin.hpp @@ -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 - void insert(It first, It last, Args &&...args) { + template + 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)...); diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index a015479d9..896c56a62 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -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 - 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(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 - void insert(It first, It last) { + template + 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().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 - void insert(It first, It last, const Type &value) { + template + 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().insert(std::move(first), std::move(last), value); } diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index f50e12c67..8cfc1f5b5 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -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 - const basic_snapshot &get(Archive &archive, It first, It last, const id_type id = type_hash::value()) const { + template + const basic_snapshot &get(Archive &archive, std::input_iterator auto first, std::input_iterator auto last, const id_type id = type_hash::value()) const { static_assert(!std::is_same_v, "Entity types not supported"); if(const auto *storage = reg->template storage(id); storage && !storage->empty()) { diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index d2b01ef5e..25abbeec7 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -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 - 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) { diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index e34dd9dca..1381da02a 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -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 - 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); }