view: stable single type view ::contains function

This commit is contained in:
Michele Caini
2023-04-26 15:49:21 +02:00
parent f54cdccd4f
commit b7a485767f
2 changed files with 2 additions and 1 deletions

View File

@@ -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);
}
/**

View File

@@ -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);