Pārlūkot izejas kodu

registry/pool: removed internal <pool>::patch overload

Michele Caini 5 gadi atpakaļ
vecāks
revīzija
46e974d201
2 mainītis faili ar 3 papildinājumiem un 25 dzēšanām
  1. 0 22
      src/entt/entity/pool.hpp
  2. 3 3
      src/entt/entity/registry.hpp

+ 0 - 22
src/entt/entity/pool.hpp

@@ -227,28 +227,6 @@ struct default_pool final: storage<Entity, Type> {
         }
     }
 
-    /**
-    * @brief Replaces the object associated with an entity in a pool.
-    *
-    * A new object is created and initialized with the arguments provided (the
-    * object type must have a proper constructor or be of aggregate type). Then
-    * the instance is assigned to the given entity.
-    *
-    * @warning
-    * Attempting to use an invalid entity or to replace an object of an entity
-    * that doesn't belong to the pool results in undefined behavior.<br/>
-    * An assertion will abort the execution at runtime in debug mode in case of
-    * invalid entity or if the entity doesn't belong to the pool.
-    *
-    * @param owner The registry that issued the request.
-    * @param entity A valid entity identifier.
-    * @param value An instance of the type to assign.
-    * @return A reference to the object being replaced.
-    */
-    decltype(auto) replace(basic_registry<entity_type> &owner, const entity_type entity, object_type value) {
-        return patch(owner, entity, [&value](auto &&curr) { curr = std::move(value); });
-    }
-
 private:
     sigh<void(basic_registry<entity_type> &, const entity_type)> construction{};
     sigh<void(basic_registry<entity_type> &, const entity_type)> destruction{};

+ 3 - 3
src/entt/entity/registry.hpp

@@ -621,8 +621,8 @@ public:
         auto &cpool = assure<Component>();
 
         return cpool.contains(entity)
-                ? cpool.replace(*this, entity, Component{std::forward<Args>(args)...})
-                : cpool.emplace(*this, entity, std::forward<Args>(args)...);
+            ? cpool.patch(*this, entity, [&args...](auto &curr) { curr = Component{std::forward<Args>(args)...}; })
+            : cpool.emplace(*this, entity, std::forward<Args>(args)...);
     }
 
     /**
@@ -680,7 +680,7 @@ public:
      */
     template<typename Component, typename... Args>
     decltype(auto) replace(const entity_type entity, Args &&... args) {
-        return assure<Component>().replace(*this, entity, Component{std::forward<Args>(args)...});
+        return assure<Component>().patch(*this, entity, [&args...](auto &curr) { curr = Component{std::forward<Args>(args)...}; });
     }
 
     /**