Преглед на файлове

view: stable multi type view ::contains function

Michele Caini преди 3 години
родител
ревизия
bdabbaa63d
променени са 2 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 1 1
      src/entt/entity/view.hpp
  2. 1 0
      test/entt/entity/view.cpp

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

@@ -462,7 +462,7 @@ public:
      * @return True if the view contains the given entity, false otherwise.
      */
     [[nodiscard]] bool contains(const entity_type entt) const noexcept {
-        return std::apply([entt](const auto *...curr) { return (curr->contains(entt) && ...); }, pools) && internal::none_of(filter, entt);
+        return view && std::apply([entt](const auto *...curr) { return (curr->contains(entt) && ...); }, pools) && internal::none_of(filter, entt);
     }
 
     /**

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

@@ -631,6 +631,7 @@ TEST(MultiComponentView, InvalidView) {
     ASSERT_FALSE(view);
 
     ASSERT_EQ(view.size_hint(), 0u);
+    ASSERT_FALSE(view.contains(entt::null));
 
     entt::storage<int> storage;
     view.storage(storage);