view: stable single type view ::size function

This commit is contained in:
Michele Caini
2023-04-26 15:48:06 +02:00
parent 736ef35805
commit 41c9a32f31
2 changed files with 3 additions and 1 deletions

View File

@@ -675,7 +675,7 @@ public:
* @return Number of entities that have the given component.
*/
[[nodiscard]] size_type size() const noexcept {
return view->size();
return view ? view->size() : size_type{};
}
/**

View File

@@ -76,6 +76,8 @@ TEST(SingleComponentView, InvalidView) {
ASSERT_FALSE(view);
ASSERT_EQ(view.size(), 0u);
entt::storage<int> storage;
view.storage(storage);