diff --git a/TODO b/TODO index ea0bd6f32..8e6e40af8 100644 --- a/TODO +++ b/TODO @@ -20,6 +20,7 @@ Next: * replace observer class with observer functions * get(cmp, entity) -> void *, set(cmp, entity, void *) +* ENTT_ENABLE_ETO -> ENTT_IS_EMPTY (ignore default constructible) * WIP: - deprecate snapshot, loader, ... diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 37dbdec51..633272976 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -335,7 +335,8 @@ public: */ template void each(Func func) const { - traverse(std::move(func), type_list{}); + using get_type_list = type_list_cat_t, type_list>...>; + traverse(std::move(func), get_type_list{}); } /** @@ -359,9 +360,9 @@ public: * @param func A valid function object. */ template + [[deprecated("use ::each instead")]] void less(Func func) const { - using get_type_list = type_list_cat_t, type_list>...>; - traverse(std::move(func), get_type_list{}); + each(std::move(func)); } /** @@ -771,7 +772,9 @@ public: */ template void each(Func func) const { - traverse(std::move(func), type_list{}, type_list{}); + using owned_type_list = type_list_cat_t, type_list>...>; + using get_type_list = type_list_cat_t, type_list>...>; + traverse(std::move(func), owned_type_list{}, get_type_list{}); } /** @@ -795,10 +798,9 @@ public: * @param func A valid function object. */ template + [[deprecated("use ::each instead")]] void less(Func func) const { - using owned_type_list = type_list_cat_t, type_list>...>; - using get_type_list = type_list_cat_t, type_list>...>; - traverse(std::move(func), owned_type_list{}, get_type_list{}); + each(std::move(func)); } /** diff --git a/test/entt/entity/group.cpp b/test/entt/entity/group.cpp index 8c0f89d9a..d77db0b00 100644 --- a/test/entt/entity/group.cpp +++ b/test/entt/entity/group.cpp @@ -305,28 +305,25 @@ TEST(NonOwningGroup, IndexRebuiltOnDestroy) { TEST(NonOwningGroup, ConstNonConstAndAllInBetween) { entt::registry registry; - auto group = registry.group(entt::get); + auto group = registry.group(entt::get); ASSERT_EQ(group.size(), decltype(group.size()){0}); const auto entity = registry.create(); registry.assign(entity, 0); registry.assign(entity, 'c'); - registry.assign(entity); ASSERT_EQ(group.size(), decltype(group.size()){1}); ASSERT_TRUE((std::is_same_v({})), int &>)); ASSERT_TRUE((std::is_same_v({})), const char &>)); - ASSERT_TRUE((std::is_same_v({})), std::true_type>)); - ASSERT_TRUE((std::is_same_v({})), std::tuple>)); + ASSERT_TRUE((std::is_same_v({})), std::tuple>)); ASSERT_TRUE((std::is_same_v()), const char *>)); ASSERT_TRUE((std::is_same_v()), int *>)); - group.each([](auto &&i, auto &&c, auto &&e) { + group.each([](auto &&i, auto &&c) { ASSERT_TRUE((std::is_same_v)); ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v)); }); } @@ -441,7 +438,7 @@ TEST(NonOwningGroup, EmptyAndNonEmptyTypes) { ASSERT_TRUE(entity == e0 || entity == e1); } - group.each([e0, e1](const auto entity, const int &, empty_type) { + group.each([e0, e1](const auto entity, const int &) { ASSERT_TRUE(entity == e0 || entity == e1); }); @@ -895,7 +892,7 @@ TEST(OwningGroup, IndexRebuiltOnDestroy) { TEST(OwningGroup, ConstNonConstAndAllInBetween) { entt::registry registry; - auto group = registry.group(entt::get); + auto group = registry.group(entt::get); ASSERT_EQ(group.size(), decltype(group.size()){0}); @@ -904,7 +901,6 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) { registry.assign(entity, 'c'); registry.assign(entity, 0.); registry.assign(entity, 0.f); - registry.assign(entity); ASSERT_EQ(group.size(), decltype(group.size()){1}); @@ -912,19 +908,17 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) { ASSERT_TRUE((std::is_same_v({})), const char &>)); ASSERT_TRUE((std::is_same_v({})), double &>)); ASSERT_TRUE((std::is_same_v({})), const float &>)); - ASSERT_TRUE((std::is_same_v({})), std::true_type>)); - ASSERT_TRUE((std::is_same_v({})), std::tuple>)); + ASSERT_TRUE((std::is_same_v({})), std::tuple>)); ASSERT_TRUE((std::is_same_v()), const float *>)); ASSERT_TRUE((std::is_same_v()), double *>)); ASSERT_TRUE((std::is_same_v()), const char *>)); ASSERT_TRUE((std::is_same_v()), int *>)); - group.each([](auto &&i, auto &&c, auto &&d, auto &&f, auto &&e) { + group.each([](auto &&i, auto &&c, auto &&d, auto &&f) { ASSERT_TRUE((std::is_same_v)); ASSERT_TRUE((std::is_same_v)); ASSERT_TRUE((std::is_same_v)); ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v)); }); } @@ -1023,7 +1017,7 @@ TEST(OwningGroup, ExcludedComponents) { TEST(OwningGroup, EmptyAndNonEmptyTypes) { entt::registry registry; - const auto group = registry.group(entt::get); + const auto group = registry.group(entt::get); const auto e0 = registry.create(); registry.assign(e0); @@ -1039,7 +1033,7 @@ TEST(OwningGroup, EmptyAndNonEmptyTypes) { ASSERT_TRUE(entity == e0 || entity == e1); } - group.each([e0, e1](const auto entity, empty_type, const int &) { + group.each([e0, e1](const auto entity, const int &) { ASSERT_TRUE(entity == e0 || entity == e1); });