Parcourir la source

storage: quit accepting (and silently discarding) arguments for empty types when invoking ::insert

skypjack il y a 6 mois
Parent
commit
47ff98e25b

+ 17 - 1
src/entt/entity/registry.hpp

@@ -610,6 +610,22 @@ public:
         return assure<Type>().emplace(entt, std::forward<Args>(args)...);
         return assure<Type>().emplace(entt, std::forward<Args>(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<typename Type, typename It>
+    void insert(It first, It 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));
+    }
+
     /**
     /**
      * @brief Assigns each entity in a range the given element.
      * @brief Assigns each entity in a range the given element.
      *
      *
@@ -622,7 +638,7 @@ public:
      * @param value An instance of the element to assign.
      * @param value An instance of the element to assign.
      */
      */
     template<typename Type, typename It>
     template<typename Type, typename It>
-    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");
         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);
         assure<Type>().insert(std::move(first), std::move(last), value);
     }
     }

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

@@ -930,13 +930,11 @@ public:
     /**
     /**
      * @brief Assigns entities to a storage.
      * @brief Assigns entities to a storage.
      * @tparam It Type of input iterator.
      * @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 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 last An iterator past the last element of the range of entities.
      */
      */
-    template<typename It, typename... Args>
-    // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
-    void insert(It first, It last, Args &&...) {
+    template<typename It>
+    void insert(It first, It last) {
         for(; first != last; ++first) {
         for(; first != last; ++first) {
             base_type::try_emplace(*first, true);
             base_type::try_emplace(*first, true);
         }
         }

+ 1 - 1
test/lib/registry/plugin/plugin.cpp

@@ -17,7 +17,7 @@ CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
         static_cast<void>(registry.storage<test::empty>());
         static_cast<void>(registry.storage<test::empty>());
 
 
         const auto view = registry.view<test::boxed_int>();
         const auto view = registry.view<test::boxed_int>();
-        registry.insert(view.begin(), view.end(), test::empty{});
+        registry.insert<test::empty>(view.begin(), view.end());
 
 
         registry.view<test::boxed_int, test::empty>().each([cnt = count](test::boxed_int &elem) {
         registry.view<test::boxed_int, test::empty>().each([cnt = count](test::boxed_int &elem) {
             elem.value += cnt;
             elem.value += cnt;