diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 487ce9281..7c69de6e6 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -610,6 +610,22 @@ public: return assure().emplace(entt, std::forward(args)...); } + /** + * @brief Assigns each entity in a range the given element. + * + * @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) { + ENTT_ASSERT(std::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity"); + assure().insert(std::move(first), std::move(last)); + } + /** * @brief Assigns each entity in a range the given element. * @@ -622,7 +638,7 @@ public: * @param value An instance of the element to assign. */ template - void insert(It first, It last, const Type &value = {}) { + void insert(It first, It 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/storage.hpp b/src/entt/entity/storage.hpp index 56084ee2a..f7bda8c86 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -930,13 +930,11 @@ public: /** * @brief Assigns entities to a storage. * @tparam It Type of input iterator. - * @tparam Args Types of optional arguments. * @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 - // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) - void insert(It first, It last, Args &&...) { + template + void insert(It first, It last) { for(; first != last; ++first) { base_type::try_emplace(*first, true); } diff --git a/test/lib/registry/plugin/plugin.cpp b/test/lib/registry/plugin/plugin.cpp index 9f0d72354..86ef5d530 100644 --- a/test/lib/registry/plugin/plugin.cpp +++ b/test/lib/registry/plugin/plugin.cpp @@ -17,7 +17,7 @@ CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { static_cast(registry.storage()); const auto view = registry.view(); - registry.insert(view.begin(), view.end(), test::empty{}); + registry.insert(view.begin(), view.end()); registry.view().each([cnt = count](test::boxed_int &elem) { elem.value += cnt;