Procházet zdrojové kódy

view: stable single type view ::contains function

Michele Caini před 2 roky
rodič
revize
b7a485767f
2 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 1 1
      src/entt/entity/view.hpp
  2. 1 0
      test/entt/entity/view.cpp

+ 1 - 1
src/entt/entity/view.hpp

@@ -798,7 +798,7 @@ public:
      * @return True if the view contains the given entity, false otherwise.
      */
     [[nodiscard]] bool contains(const entity_type entt) const noexcept {
-        return view->contains(entt);
+        return view && view->contains(entt);
     }
 
     /**

+ 1 - 0
test/entt/entity/view.cpp

@@ -78,6 +78,7 @@ TEST(SingleComponentView, InvalidView) {
 
     ASSERT_EQ(view.size(), 0u);
     ASSERT_TRUE(view.empty());
+    ASSERT_FALSE(view.contains(entt::null));
 
     entt::storage<int> storage;
     view.storage(storage);