Kaynağa Gözat

*: refine code that msvc accepts by mistake (:man_facepalming:)

Michele Caini 5 yıl önce
ebeveyn
işleme
8149e204d2

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

@@ -751,7 +751,7 @@ public:
     size_type remove_if_exists(const entity_type entity) {
         ENTT_ASSERT(valid(entity));
 
-        return ([this, entity](auto *cpool) {
+        return ([entity](auto *cpool) {
             return cpool->contains(entity) ? (cpool->remove(entity), true) : false;
         }(assure<Component>()) + ... + size_type{});
     }
@@ -930,7 +930,7 @@ public:
 
             each([this](const auto entity) { release_entity(entity, version(entity) + 1u); });
         } else {
-            ([this](auto *cpool) {
+            ([](auto *cpool) {
                 cpool->remove(cpool->basic_sparse_set<entity_type>::begin(), cpool->basic_sparse_set<entity_type>::end());
             }(assure<Component>()), ...);
         }

+ 9 - 8
src/entt/entity/storage.hpp

@@ -394,8 +394,9 @@ public:
      */
     template<typename... Func>
     decltype(auto) patch(const entity_type entity, [[maybe_unused]] Func &&... func) {
-        (std::forward<Func>(func)(instances[index(entity)]), ...);
-        return instances[index(entity)];
+        auto &&instance = instances[this->index(entity)];
+        (std::forward<Func>(func)(instance), ...);
+        return instance;
     }
 
     /**
@@ -531,7 +532,7 @@ public:
      * @param entt A valid entity identifier.
      */
     void get([[maybe_unused]] const entity_type entt) const {
-        ENTT_ASSERT(contains(entt));
+        ENTT_ASSERT(this->contains(entt));
     }
 
     /**
@@ -559,7 +560,7 @@ public:
     */
     template<typename... Func>
     void patch([[maybe_unused]] const entity_type entity, [[maybe_unused]] Func &&... func) {
-        ENTT_ASSERT(contains(entity));
+        ENTT_ASSERT(this->contains(entity));
         (std::forward<Func>(func)(), ...);
     }
 
@@ -589,13 +590,13 @@ public:
 template<typename Type, typename Owner>
 class sigh_storage_mixin: public Type {
     Owner & owner() ENTT_NOEXCEPT {
-        return *static_cast<Owner *>(payload());
+        return *static_cast<Owner *>(this->payload());
     }
 
 protected:
     /*! @copydoc basic_storage::swap_and_pop */
     void swap_and_pop(const std::size_t pos) {
-        destruction.publish(owner(), data()[pos]);
+        destruction.publish(owner(), this->data()[pos]);
         Type::swap_and_pop(pos);
     }
 
@@ -683,7 +684,7 @@ public:
     decltype(auto) emplace(const entity_type entity, Args &&... args) {
         Type::emplace(entity, std::forward<Args>(args)...);
         construction.publish(owner(), entity);
-        return get(entity);
+        return this->get(entity);
     }
 
     /**
@@ -718,7 +719,7 @@ public:
     decltype(auto) patch(const entity_type entity, [[maybe_unused]] Func &&... func) {
         Type::patch(entity, std::forward<Func>(func)...);
         update.publish(owner(), entity);
-        return get(entity);
+        return this->get(entity);
     }
 
 private:

+ 0 - 6
test/entt/entity/registry.cpp

@@ -291,12 +291,6 @@ TEST(Registry, Move) {
     registry.emplace<int>(registry.create(entity));
 
     ASSERT_EQ(test.parent, &registry);
-
-    test.parent = nullptr;
-    registry = std::move(registry);
-    registry.remove<int>(entity);
-
-    ASSERT_EQ(test.parent, &registry);
 }
 
 TEST(Registry, ReplaceAggregate) {