view: stable single type view ::each(cb) function
This commit is contained in:
@@ -850,6 +850,7 @@ public:
|
||||
*/
|
||||
template<typename Func>
|
||||
void each(Func func) const {
|
||||
if(view) {
|
||||
if constexpr(is_applicable_v<Func, decltype(*each().begin())>) {
|
||||
for(const auto pack: each()) {
|
||||
std::apply(func, pack);
|
||||
@@ -864,6 +865,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns an iterable object to use to _visit_ a view.
|
||||
|
||||
@@ -94,10 +94,16 @@ TEST(SingleComponentView, InvalidView) {
|
||||
ASSERT_EQ(iterable.begin(), iterable.end());
|
||||
ASSERT_EQ(iterable.cbegin(), iterable.cend());
|
||||
|
||||
view.each([](const int &) { FAIL(); });
|
||||
view.each([](const entt::entity, const int &) { FAIL(); });
|
||||
|
||||
entt::storage<int> storage;
|
||||
view.storage(storage);
|
||||
|
||||
ASSERT_TRUE(view);
|
||||
|
||||
view.each([](const int &) { FAIL(); });
|
||||
view.each([](const entt::entity, const int &) { FAIL(); });
|
||||
}
|
||||
|
||||
TEST(SingleComponentView, Constructors) {
|
||||
|
||||
Reference in New Issue
Block a user