view: added ::refresh function to reinitialize the leading pool
This commit is contained in:
@@ -52,7 +52,9 @@ public:
|
||||
last{to},
|
||||
pools{all_of},
|
||||
filter{none_of} {
|
||||
while(it != last && !valid()) { ++it; }
|
||||
while(it != last && !valid()) {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
view_iterator &operator++() noexcept {
|
||||
@@ -295,6 +297,14 @@ public:
|
||||
return other;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the internal leading view if required.
|
||||
* @return A newly created and internally optimized view.
|
||||
*/
|
||||
[[nodiscard]] basic_view refresh() const noexcept {
|
||||
return std::apply([](auto *...elem) { return basic_view{*elem...}; }, std::tuple_cat(pools, filter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the leading storage of a view.
|
||||
* @return The leading storage of the view.
|
||||
|
||||
@@ -563,7 +563,7 @@ TEST(MultiComponentView, Handle) {
|
||||
ASSERT_TRUE(handle.contains(entity));
|
||||
ASSERT_EQ(&handle, &view.handle());
|
||||
|
||||
view = registry.view<int, char>();
|
||||
view = view.refresh();
|
||||
auto &&other = view.handle();
|
||||
|
||||
ASSERT_TRUE(other.empty());
|
||||
|
||||
Reference in New Issue
Block a user