view: stable multi type view ::size_hint function

This commit is contained in:
Michele Caini
2023-04-28 15:44:00 +02:00
parent f1a2133820
commit c79c109b77
2 changed files with 3 additions and 1 deletions

View File

@@ -379,7 +379,7 @@ public:
* @return Estimated number of entities iterated by the view.
*/
[[nodiscard]] size_type size_hint() const noexcept {
return view->size();
return view ? view->size() : size_type{};
}
/**

View File

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