Ver código fonte

group: try to reuse pools when sorting and also please all compilers out there at the same time (aka me figthing ICEs again)

Michele Caini 3 anos atrás
pai
commit
7941226eff
1 arquivos alterados com 6 adições e 6 exclusões
  1. 6 6
      src/entt/entity/group.hpp

+ 6 - 6
src/entt/entity/group.hpp

@@ -602,11 +602,11 @@ public:
                 static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
                 descriptor->group().sort(std::move(compare), std::move(algo), std::forward<Args>(args)...);
             } else {
-                auto comp = [&compare, cpools = std::forward_as_tuple(storage<index_of<Type>>()...)](const entity_type lhs, const entity_type rhs) {
+                auto comp = [&compare, cpools = pools()](const entity_type lhs, const entity_type rhs) {
                     if constexpr(sizeof...(Type) == 1) {
-                        return compare(std::get<0>(cpools).get(lhs), std::get<0>(cpools).get(rhs));
+                        return compare((std::get<index_of<Type>>(cpools)->get(lhs), ...), (std::get<index_of<Type>>(cpools)->get(rhs), ...));
                     } else {
-                        return std::apply([&compare, lhs, rhs](auto &...cpool) { return compare(std::forward_as_tuple(cpool.get(lhs)...), std::forward_as_tuple(cpool.get(rhs)...)); }, cpools);
+                        return compare(std::forward_as_tuple(std::get<index_of<Type>>(cpools)->get(lhs)...), std::forward_as_tuple(std::get<index_of<Type>>(cpools)->get(rhs)...));
                     }
                 };
 
@@ -991,11 +991,11 @@ public:
             static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
             storage<0>().sort_n(descriptor->length(), std::move(compare), std::move(algo), std::forward<Args>(args)...);
         } else {
-            auto comp = [&compare, cpools = std::forward_as_tuple(storage<index_of<Type>>()...)](const entity_type lhs, const entity_type rhs) {
+            auto comp = [&compare, cpools = pools()](const entity_type lhs, const entity_type rhs) {
                 if constexpr(sizeof...(Type) == 1) {
-                    return compare(std::get<0>(cpools).get(lhs), std::get<0>(cpools).get(rhs));
+                    return compare((std::get<index_of<Type>>(cpools)->get(lhs), ...), (std::get<index_of<Type>>(cpools)->get(rhs), ...));
                 } else {
-                    return std::apply([&compare, lhs, rhs](auto &...cpool) { return compare(std::forward_as_tuple(cpool.get(lhs)...), std::forward_as_tuple(cpool.get(rhs)...)); }, cpools);
+                    return compare(std::forward_as_tuple(std::get<index_of<Type>>(cpools)->get(lhs)...), std::forward_as_tuple(std::get<index_of<Type>>(cpools)->get(rhs)...));
                 }
             };