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

This commit is contained in:
Michele Caini
2023-03-18 12:48:52 +01:00
parent 86bbb2f6bb
commit 7941226eff
+6 -6
View File
@@ -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)...));
}
};