view: turn ::refresh into a self contained, non-const function
This commit is contained in:
@@ -268,7 +268,7 @@ public:
|
||||
: pools{&value...},
|
||||
filter{&excl...},
|
||||
view{std::get<0>(pools)} {
|
||||
((view = value.size() < view->size() ? &value : view), ...);
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,12 +301,9 @@ 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, internal::filter_as_tuple<Exclude...>(filter)));
|
||||
/*! @brief Updates the internal leading view if required. */
|
||||
void refresh() noexcept {
|
||||
std::apply([this](auto *...elem) { ((view = elem->size() < view->size() ? elem : view), ...); }, pools);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -995,8 +995,11 @@ TEST(Registry, View) {
|
||||
ASSERT_EQ(mview.size_hint(), 3u);
|
||||
ASSERT_EQ(fview.size_hint(), 3u);
|
||||
|
||||
ASSERT_EQ(mview.refresh().size_hint(), 2u);
|
||||
ASSERT_EQ(fview.refresh().size_hint(), 3u);
|
||||
mview.refresh();
|
||||
fview.refresh();
|
||||
|
||||
ASSERT_EQ(mview.size_hint(), 2u);
|
||||
ASSERT_EQ(fview.size_hint(), 3u);
|
||||
|
||||
ASSERT_NE(mview.begin(), mview.end());
|
||||
ASSERT_NE(fview.begin(), fview.end());
|
||||
|
||||
@@ -582,7 +582,7 @@ TEST(MultiComponentView, Handle) {
|
||||
ASSERT_TRUE(handle.contains(entity));
|
||||
ASSERT_EQ(&handle, &view.handle());
|
||||
|
||||
view = view.refresh();
|
||||
view.refresh();
|
||||
auto &&other = view.handle();
|
||||
|
||||
ASSERT_TRUE(other.empty());
|
||||
|
||||
Reference in New Issue
Block a user