|
|
@@ -245,35 +245,33 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
|
|
|
|
|
|
template<typename Comp, typename Func>
|
|
|
void traverse(Func func) const {
|
|
|
- if(*this) {
|
|
|
- if constexpr(std::is_same_v<typename storage_type<Comp>::storage_category, empty_storage_tag>) {
|
|
|
- for(const auto entt: static_cast<const basic_sparse_set<entity_type> &>(*std::get<storage_type<Comp> *>(pools))) {
|
|
|
- if(((std::is_same_v<Comp, Component> || std::get<storage_type<Component> *>(pools)->contains(entt)) && ...)
|
|
|
- && !(std::get<const storage_type<Exclude> *>(filter)->contains(entt) || ...))
|
|
|
- {
|
|
|
- if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
|
|
|
- std::apply(func, std::tuple_cat(std::make_tuple(entt), get(entt)));
|
|
|
- } else {
|
|
|
- std::apply(func, get(entt));
|
|
|
- }
|
|
|
+ if constexpr(std::is_same_v<typename storage_type<Comp>::storage_category, empty_storage_tag>) {
|
|
|
+ for(const auto entt: static_cast<const basic_sparse_set<entity_type> &>(*std::get<storage_type<Comp> *>(pools))) {
|
|
|
+ if(((std::is_same_v<Comp, Component> || std::get<storage_type<Component> *>(pools)->contains(entt)) && ...)
|
|
|
+ && !(std::get<const storage_type<Exclude> *>(filter)->contains(entt) || ...))
|
|
|
+ {
|
|
|
+ if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
|
|
|
+ std::apply(func, std::tuple_cat(std::make_tuple(entt), get(entt)));
|
|
|
+ } else {
|
|
|
+ std::apply(func, get(entt));
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- auto it = std::get<storage_type<Comp> *>(pools)->begin();
|
|
|
-
|
|
|
- for(const auto entt: static_cast<const basic_sparse_set<entity_type> &>(*std::get<storage_type<Comp> *>(pools))) {
|
|
|
- if(((std::is_same_v<Comp, Component> || std::get<storage_type<Component> *>(pools)->contains(entt)) && ...)
|
|
|
- && !(std::get<const storage_type<Exclude> *>(filter)->contains(entt) || ...))
|
|
|
- {
|
|
|
- if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
|
|
|
- std::apply(func, std::tuple_cat(std::make_tuple(entt), dispatch_get<Component>(it, entt)...));
|
|
|
- } else {
|
|
|
- std::apply(func, std::tuple_cat(dispatch_get<Component>(it, entt)...));
|
|
|
- }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ auto it = std::get<storage_type<Comp> *>(pools)->begin();
|
|
|
+
|
|
|
+ for(const auto entt: static_cast<const basic_sparse_set<entity_type> &>(*std::get<storage_type<Comp> *>(pools))) {
|
|
|
+ if(((std::is_same_v<Comp, Component> || std::get<storage_type<Component> *>(pools)->contains(entt)) && ...)
|
|
|
+ && !(std::get<const storage_type<Exclude> *>(filter)->contains(entt) || ...))
|
|
|
+ {
|
|
|
+ if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
|
|
|
+ std::apply(func, std::tuple_cat(std::make_tuple(entt), dispatch_get<Component>(it, entt)...));
|
|
|
+ } else {
|
|
|
+ std::apply(func, std::tuple_cat(dispatch_get<Component>(it, entt)...));
|
|
|
}
|
|
|
-
|
|
|
- ++it;
|
|
|
}
|
|
|
+
|
|
|
+ ++it;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -310,7 +308,7 @@ public:
|
|
|
*/
|
|
|
template<typename Comp>
|
|
|
void use() const ENTT_NOEXCEPT {
|
|
|
- view = *this ? std::get<storage_type<Comp> *>(pools) : nullptr;
|
|
|
+ view = std::get<storage_type<Comp> *>(pools);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -318,7 +316,7 @@ public:
|
|
|
* @return Estimated number of entities iterated by the view.
|
|
|
*/
|
|
|
[[nodiscard]] size_type size_hint() const ENTT_NOEXCEPT {
|
|
|
- return *this ? view->size() : size_type{};
|
|
|
+ return view->size();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -330,7 +328,7 @@ public:
|
|
|
* @return An iterator to the first entity of the view.
|
|
|
*/
|
|
|
[[nodiscard]] iterator begin() const {
|
|
|
- return *this ? iterator{view->begin(), view->end(), view->begin(), unchecked(view), filter} : iterator{};
|
|
|
+ return iterator{view->begin(), view->end(), view->begin(), unchecked(view), filter};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -343,7 +341,7 @@ public:
|
|
|
* @return An iterator to the entity following the last entity of the view.
|
|
|
*/
|
|
|
[[nodiscard]] iterator end() const {
|
|
|
- return *this ? iterator{view->begin(), view->end(), view->end(), unchecked(view), filter} : iterator{};
|
|
|
+ return iterator{view->begin(), view->end(), view->end(), unchecked(view), filter};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -355,7 +353,7 @@ public:
|
|
|
* @return An iterator to the first entity of the reversed view.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rbegin() const {
|
|
|
- return *this ? reverse_iterator{view->rbegin(), view->rend(), view->rbegin(), unchecked(view), filter} : reverse_iterator{};
|
|
|
+ return reverse_iterator{view->rbegin(), view->rend(), view->rbegin(), unchecked(view), filter};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -370,7 +368,7 @@ public:
|
|
|
* reversed view.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rend() const {
|
|
|
- return *this ? reverse_iterator{view->rbegin(), view->rend(), view->rend(), unchecked(view), filter} : reverse_iterator{};
|
|
|
+ return reverse_iterator{view->rbegin(), view->rend(), view->rend(), unchecked(view), filter};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -400,7 +398,7 @@ public:
|
|
|
* iterator otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] iterator find(const entity_type entt) const {
|
|
|
- const auto it = *this ? iterator{view->begin(), view->end(), view->find(entt), unchecked(view), filter} : end();
|
|
|
+ const auto it = iterator{view->begin(), view->end(), view->find(entt), unchecked(view), filter};
|
|
|
return (it != end() && *it == entt) ? it : end();
|
|
|
}
|
|
|
|
|
|
@@ -418,7 +416,7 @@ public:
|
|
|
* @return True if the view contains the given entity, false otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] bool contains(const entity_type entt) const {
|
|
|
- return *this && (std::get<storage_type<Component> *>(pools)->contains(entt) && ...) && !(std::get<const storage_type<Exclude> *>(filter)->contains(entt) || ...);
|
|
|
+ return (std::get<storage_type<Component> *>(pools)->contains(entt) && ...) && !(std::get<const storage_type<Exclude> *>(filter)->contains(entt) || ...);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -445,7 +443,8 @@ public:
|
|
|
} else if constexpr(sizeof...(Comp) == 1) {
|
|
|
return (std::get<storage_type<Comp> *>(pools)->get(entt), ...);
|
|
|
} else {
|
|
|
- return std::tuple_cat(get_as_tuple(*std::get<storage_type<Comp> *>(pools), entt)...); }
|
|
|
+ return std::tuple_cat(get_as_tuple(*std::get<storage_type<Comp> *>(pools), entt)...);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -690,7 +689,7 @@ public:
|
|
|
* @return Number of entities that have the given component.
|
|
|
*/
|
|
|
[[nodiscard]] size_type size() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->size() : size_type{};
|
|
|
+ return pool->size();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -698,7 +697,7 @@ public:
|
|
|
* @return True if the view is empty, false otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] bool empty() const ENTT_NOEXCEPT {
|
|
|
- return !*this || pool->empty();
|
|
|
+ return pool->empty();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -710,7 +709,7 @@ public:
|
|
|
* @return A pointer to the array of components.
|
|
|
*/
|
|
|
[[nodiscard]] raw_type * raw() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->raw() : nullptr;
|
|
|
+ return pool->raw();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -722,7 +721,7 @@ public:
|
|
|
* @return A pointer to the array of entities.
|
|
|
*/
|
|
|
[[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->data() : nullptr;
|
|
|
+ return pool->data();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -734,7 +733,7 @@ public:
|
|
|
* @return An iterator to the first entity of the view.
|
|
|
*/
|
|
|
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->basic_sparse_set<entity_type>::begin() : iterator{};
|
|
|
+ return pool->basic_sparse_set<entity_type>::begin();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -747,7 +746,7 @@ public:
|
|
|
* @return An iterator to the entity following the last entity of the view.
|
|
|
*/
|
|
|
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->basic_sparse_set<entity_type>::end() : iterator{};
|
|
|
+ return pool->basic_sparse_set<entity_type>::end();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -759,7 +758,7 @@ public:
|
|
|
* @return An iterator to the first entity of the reversed view.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->basic_sparse_set<entity_type>::rbegin() : reverse_iterator{};
|
|
|
+ return pool->basic_sparse_set<entity_type>::rbegin();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -774,7 +773,7 @@ public:
|
|
|
* reversed view.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT {
|
|
|
- return *this ? pool->basic_sparse_set<entity_type>::rend() : reverse_iterator{};
|
|
|
+ return pool->basic_sparse_set<entity_type>::rend();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -804,7 +803,7 @@ public:
|
|
|
* iterator otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] iterator find(const entity_type entt) const {
|
|
|
- const auto it = *this ? pool->find(entt) : end();
|
|
|
+ const auto it = pool->find(entt);
|
|
|
return it != end() && *it == entt ? it : end();
|
|
|
}
|
|
|
|
|
|
@@ -831,7 +830,7 @@ public:
|
|
|
* @return True if the view contains the given entity, false otherwise.
|
|
|
*/
|
|
|
[[nodiscard]] bool contains(const entity_type entt) const {
|
|
|
- return *this && pool->contains(entt);
|
|
|
+ return pool->contains(entt);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -901,10 +900,8 @@ public:
|
|
|
std::apply(func, pack);
|
|
|
}
|
|
|
} else {
|
|
|
- if(*this) {
|
|
|
- for(auto &&component: *pool) {
|
|
|
- func(component);
|
|
|
- }
|
|
|
+ for(auto &&component: *pool) {
|
|
|
+ func(component);
|
|
|
}
|
|
|
}
|
|
|
}
|