Explorar el Código

registry: drop internal static storage variables from ::assure

Michele Caini hace 2 años
padre
commit
12186cb401
Se han modificado 2 ficheros con 6 adiciones y 7 borrados
  1. 2 3
      src/entt/entity/registry.hpp
  2. 4 4
      test/entt/entity/view.cpp

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

@@ -279,8 +279,7 @@ class basic_registry {
             return static_cast<const storage_for_type<Type> *>(it->second.get());
         }
 
-        static storage_for_type<Type> placeholder{};
-        return &placeholder;
+        return static_cast<const storage_for_type<Type> *>(nullptr);
     }
 
     void rebind() {
@@ -961,7 +960,7 @@ public:
             return cpool && cpool->contains(entt);
         } else {
             return (all_of<Type>(entt) && ...);
-    }
+        }
     }
 
     /**

+ 4 - 4
test/entt/entity/view.cpp

@@ -150,8 +150,8 @@ TEST(SingleComponentView, LazyTypeFromConstRegistry) {
     registry.emplace<empty_type>(entity);
     registry.emplace<int>(entity);
 
-    ASSERT_TRUE(cview);
-    ASSERT_TRUE(eview);
+    ASSERT_FALSE(cview);
+    ASSERT_FALSE(eview);
 
     ASSERT_TRUE(cview.empty());
     ASSERT_EQ(eview.size(), 0u);
@@ -723,7 +723,7 @@ TEST(MultiComponentView, LazyTypesFromConstRegistry) {
     registry.emplace<empty_type>(entity);
     registry.emplace<int>(entity);
 
-    ASSERT_TRUE(view);
+    ASSERT_FALSE(view);
 
     ASSERT_EQ(view.size_hint(), 0u);
     ASSERT_FALSE(view.contains(entity));
@@ -742,7 +742,7 @@ TEST(MultiComponentView, LazyExcludedTypeFromConstRegistry) {
 
     auto view = std::as_const(registry).view<const int>(entt::exclude<char>);
 
-    ASSERT_TRUE(view);
+    ASSERT_FALSE(view);
 
     ASSERT_EQ(view.size_hint(), 1u);
     ASSERT_TRUE(view.contains(entity));