Kaynağa Gözat

view/group: try to get around an issue of gcc v7.5 + suppress some warnings here and there

Michele Caini 5 yıl önce
ebeveyn
işleme
0507680cc1

+ 1 - 0
TODO

@@ -25,6 +25,7 @@ WIP:
 * add exclude-only views to combine with packs
 * deprecate non-owning groups in favor of owning views and view packs, introduce lazy owning views
 * HP: write documentation for custom storages and views!!
+* use views within the registry, do not duplicate the logic for some operations
 * view pack: optimize it and iterate only first min size hint entities
 * view pack: plain function as an alias for operator|, reverse iterators, rbegin and rend
 * what about using hashed string rather than hash values for meta types?

+ 1 - 1
src/entt/entity/registry.hpp

@@ -800,7 +800,7 @@ public:
     template<typename... Component>
     [[nodiscard]] bool any(const entity_type entity) const {
         ENTT_ASSERT(valid(entity));
-        return [entity](auto *... cpool) { return ((cpool && cpool->contains(entity)) || ...); }(assure<Component>()...);
+        return (has<Component>(entity) || ...);
     }
 
     /**

+ 6 - 2
src/entt/entity/view.hpp

@@ -100,7 +100,9 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
         using reference = typename std::iterator_traits<It>::reference;
         using iterator_category = std::bidirectional_iterator_tag;
 
-        view_iterator() ENTT_NOEXCEPT = default;
+        view_iterator() ENTT_NOEXCEPT
+            : view_iterator{{}, {}, {}, {}, {}}
+        {}
 
         view_iterator & operator++() ENTT_NOEXCEPT {
             while(++it != last && !valid());
@@ -581,7 +583,9 @@ class basic_view<Entity, exclude_t<>, Component> final {
         class iterable_view_iterator {
             friend class iterable_view;
 
-            iterable_view_iterator() ENTT_NOEXCEPT = default;
+            iterable_view_iterator() ENTT_NOEXCEPT
+                : iterable_view_iterator{It{}...}
+            {}
 
             template<typename... Discard>
             iterable_view_iterator(It... from, Discard...) ENTT_NOEXCEPT

+ 2 - 2
test/entt/entity/group.cpp

@@ -105,7 +105,7 @@ TEST(NonOwningGroup, Invalid) {
     group.each([](const auto, const auto &) { FAIL(); });
     group.each([](const auto &) { FAIL(); });
 
-    for(auto [entity, value]: group.each()) { FAIL(); }
+    for([[maybe_unused]] const auto all: group.each()) { FAIL(); }
     for(auto first = group.each().rbegin(), last = group.each().rend(); first != last; ++first) { FAIL(); }
 
     ASSERT_NO_THROW(group.sort([](const auto, const auto) { FAIL(), true; }));
@@ -677,7 +677,7 @@ TEST(OwningGroup, Invalid) {
     group.each([](const auto, const auto &) { FAIL(); });
     group.each([](const auto &) { FAIL(); });
 
-    for(auto [entity, value]: group.each()) { FAIL(); }
+    for([[maybe_unused]] const auto all: group.each()) { FAIL(); }
     for(auto first = group.each().rbegin(), last = group.each().rend(); first != last; ++first) { FAIL(); }
 }
 

+ 3 - 3
test/entt/entity/view.cpp

@@ -95,10 +95,10 @@ TEST(SingleComponentView, Invalid) {
     eview.each([](const auto) { FAIL(); });
     eview.each([]() { FAIL(); });
 
-    for(auto [entity, value]: cview.each()) { FAIL(); }
+    for([[maybe_unused]] const auto all: cview.each()) { FAIL(); }
     for(auto first = cview.each().rbegin(), last = cview.each().rend(); first != last; ++first) { FAIL(); }
 
-    for(const auto entity: eview.each()) { FAIL(); }
+    for([[maybe_unused]] const auto entt: eview.each()) { FAIL(); }
     for(auto first = eview.each().rbegin(), last = eview.each().rend(); first != last; ++first) { FAIL(); }
 }
 
@@ -424,7 +424,7 @@ TEST(MultiComponentView, Invalid) {
     view.each([](const auto, const auto &) { FAIL(); });
     view.each([](const auto &) { FAIL(); });
 
-    for(auto [entity, value]: view.each()) { FAIL(); }
+    for([[maybe_unused]] const auto all: view.each()) { FAIL(); }
     for(auto first = view.each().rbegin(), last = view.each().rend(); first != last; ++first) { FAIL(); }
 }