view: stable single type view ::each() function

This commit is contained in:
Michele Caini
2023-04-27 09:19:57 +02:00
parent 873b107e69
commit 5be2fdc158
2 changed files with 6 additions and 1 deletions

View File

@@ -877,7 +877,7 @@ public:
* @return An iterable object to use to _visit_ the view.
*/
[[nodiscard]] iterable each() const noexcept {
return std::get<0>(pools)->each();
return view ? std::get<0>(pools)->each() : iterable{};
}
/**

View File

@@ -90,6 +90,11 @@ TEST(SingleComponentView, InvalidView) {
ASSERT_EQ(view.rbegin(), typename decltype(view)::reverse_iterator{});
ASSERT_EQ(view.rbegin(), view.rend());
auto iterable = view.each();
ASSERT_EQ(iterable.begin(), iterable.end());
ASSERT_EQ(iterable.cbegin(), iterable.cend());
entt::storage<int> storage;
view.storage(storage);