|
|
@@ -131,7 +131,7 @@ class basic_group<Entity, owned_t<>, get_t<Get...>, exclude_t<Exclude...>> {
|
|
|
friend class basic_registry<Entity>;
|
|
|
|
|
|
template<typename Comp>
|
|
|
- static constexpr auto index_of = type_list_index_v<std::remove_const_t<Comp>, type_list<std::remove_const_t<Get>...>>;
|
|
|
+ static constexpr std::size_t index_of = type_list_index_v<std::remove_const_t<Comp>, type_list<std::remove_const_t<Get>...>>;
|
|
|
|
|
|
template<typename Comp>
|
|
|
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Comp>>::storage_type, Comp>;
|
|
|
@@ -175,7 +175,7 @@ public:
|
|
|
*/
|
|
|
template<typename Comp>
|
|
|
[[nodiscard]] decltype(auto) storage() const ENTT_NOEXCEPT {
|
|
|
- return storage<index_of<Comp>>();
|
|
|
+ return *std::get<index_of<Comp>>(pools);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -352,9 +352,9 @@ public:
|
|
|
if constexpr(sizeof...(Comp) == 0) {
|
|
|
return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, pools);
|
|
|
} else if constexpr(sizeof...(Comp) == 1) {
|
|
|
- return (storage<Comp>().get(entt), ...);
|
|
|
+ return (std::get<index_of<Comp>>(pools)->get(entt), ...);
|
|
|
} else {
|
|
|
- return std::tuple_cat(storage<Comp>().get_as_tuple(entt)...);
|
|
|
+ return std::tuple_cat(std::get<index_of<Comp>>(pools)->get_as_tuple(entt)...);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -453,9 +453,9 @@ public:
|
|
|
} else {
|
|
|
auto comp = [this, &compare](const entity_type lhs, const entity_type rhs) {
|
|
|
if constexpr(sizeof...(Comp) == 1) {
|
|
|
- return compare((storage<Comp>().get(lhs), ...), (storage<Comp>().get(rhs), ...));
|
|
|
+ return compare((std::get<index_of<Comp>>(pools)->get(lhs), ...), (std::get<index_of<Comp>>(pools)->get(rhs), ...));
|
|
|
} else {
|
|
|
- return compare(std::forward_as_tuple(storage<Comp>().get(lhs)...), std::forward_as_tuple(storage<Comp>().get(rhs)...));
|
|
|
+ return compare(std::forward_as_tuple(std::get<index_of<Comp>>(pools)->get(lhs)...), std::forward_as_tuple(std::get<index_of<Comp>>(pools)->get(rhs)...));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -483,7 +483,7 @@ public:
|
|
|
template<typename Comp>
|
|
|
void sort() const {
|
|
|
if(*this) {
|
|
|
- handler->respect(storage<Comp>());
|
|
|
+ handler->respect(*std::get<index_of<Comp>>(pools));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -531,7 +531,7 @@ class basic_group<Entity, owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...
|
|
|
friend class basic_registry<Entity>;
|
|
|
|
|
|
template<typename Comp>
|
|
|
- static constexpr auto index_of = type_list_index_v<std::remove_const_t<Comp>, type_list<std::remove_const_t<Owned>..., std::remove_const_t<Get>...>>;
|
|
|
+ static constexpr std::size_t index_of = type_list_index_v<std::remove_const_t<Comp>, type_list<std::remove_const_t<Owned>..., std::remove_const_t<Get>...>>;
|
|
|
|
|
|
template<typename Comp>
|
|
|
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Comp>>::storage_type, Comp>;
|
|
|
@@ -565,7 +565,7 @@ public:
|
|
|
*/
|
|
|
template<typename Comp>
|
|
|
[[nodiscard]] decltype(auto) storage() const ENTT_NOEXCEPT {
|
|
|
- return storage<index_of<Comp>>();
|
|
|
+ return *std::get<index_of<Comp>>(pools);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -603,7 +603,7 @@ public:
|
|
|
* @return An iterator to the first entity of the group.
|
|
|
*/
|
|
|
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
|
|
|
- return *this ? (storage<0>().base_type::end() - *length) : iterator{};
|
|
|
+ return *this ? (std::get<0>(pools)->base_type::end() - *length) : iterator{};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -617,7 +617,7 @@ public:
|
|
|
* group.
|
|
|
*/
|
|
|
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
|
|
|
- return *this ? storage<0>().base_type::end() : iterator{};
|
|
|
+ return *this ? std::get<0>(pools)->base_type::end() : iterator{};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -629,7 +629,7 @@ public:
|
|
|
* @return An iterator to the first entity of the reversed group.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT {
|
|
|
- return *this ? storage<0>().base_type::rbegin() : reverse_iterator{};
|
|
|
+ return *this ? std::get<0>(pools)->base_type::rbegin() : reverse_iterator{};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -644,7 +644,7 @@ public:
|
|
|
* reversed group.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT {
|
|
|
- return *this ? (storage<0>().base_type::rbegin() + *length) : reverse_iterator{};
|
|
|
+ return *this ? (std::get<0>(pools)->base_type::rbegin() + *length) : reverse_iterator{};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -674,7 +674,7 @@ public:
|
|
|
* iterator otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] iterator find(const entity_type entt) const ENTT_NOEXCEPT {
|
|
|
- const auto it = *this ? storage<0>().find(entt) : iterator{};
|
|
|
+ const auto it = *this ? std::get<0>(pools)->find(entt) : iterator{};
|
|
|
return it != end() && it >= begin() && *it == entt ? it : end();
|
|
|
}
|
|
|
|
|
|
@@ -701,7 +701,7 @@ public:
|
|
|
* @return True if the group contains the given entity, false otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] bool contains(const entity_type entt) const ENTT_NOEXCEPT {
|
|
|
- return *this && storage<0>().contains(entt) && (storage<0>().index(entt) < (*length));
|
|
|
+ return *this && std::get<0>(pools)->contains(entt) && (std::get<0>(pools)->index(entt) < (*length));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -726,9 +726,9 @@ public:
|
|
|
if constexpr(sizeof...(Comp) == 0) {
|
|
|
return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, pools);
|
|
|
} else if constexpr(sizeof...(Comp) == 1) {
|
|
|
- return (storage<Comp>().get(entt), ...);
|
|
|
+ return (std::get<index_of<Comp>>(pools)->get(entt), ...);
|
|
|
} else {
|
|
|
- return std::tuple_cat(storage<Comp>().get_as_tuple(entt)...);
|
|
|
+ return std::tuple_cat(std::get<index_of<Comp>>(pools)->get_as_tuple(entt)...);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -823,17 +823,17 @@ public:
|
|
|
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) const {
|
|
|
if constexpr(sizeof...(Comp) == 0) {
|
|
|
static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
|
|
|
- storage<0>().sort_n(*length, std::move(compare), std::move(algo), std::forward<Args>(args)...);
|
|
|
+ std::get<0>(pools)->sort_n(*length, std::move(compare), std::move(algo), std::forward<Args>(args)...);
|
|
|
} else {
|
|
|
auto comp = [this, &compare](const entity_type lhs, const entity_type rhs) {
|
|
|
if constexpr(sizeof...(Comp) == 1) {
|
|
|
- return compare((storage<Comp>().get(lhs), ...), (storage<Comp>().get(rhs), ...));
|
|
|
+ return compare((std::get<index_of<Comp>>(pools)->get(lhs), ...), (std::get<index_of<Comp>>(pools)->get(rhs), ...));
|
|
|
} else {
|
|
|
- return compare(std::forward_as_tuple(storage<Comp>().get(lhs)...), std::forward_as_tuple(storage<Comp>().get(rhs)...));
|
|
|
+ return compare(std::forward_as_tuple(std::get<index_of<Comp>>(pools)->get(lhs)...), std::forward_as_tuple(std::get<index_of<Comp>>(pools)->get(rhs)...));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- storage<0>().sort_n(*length, std::move(comp), std::move(algo), std::forward<Args>(args)...);
|
|
|
+ std::get<0>(pools)->sort_n(*length, std::move(comp), std::move(algo), std::forward<Args>(args)...);
|
|
|
}
|
|
|
|
|
|
[this](auto &head, auto &...other) {
|
|
|
@@ -842,7 +842,7 @@ public:
|
|
|
[[maybe_unused]] const auto entt = head.data()[pos];
|
|
|
(other.swap_elements(other.data()[pos], entt), ...);
|
|
|
}
|
|
|
- }(storage<Owned>()...);
|
|
|
+ }(*std::get<index_of<Owned>>(pools)...);
|
|
|
}
|
|
|
|
|
|
private:
|