diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index ba886e971..d5f10d179 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -80,11 +80,12 @@ class basic_view, Component...> { using underlying_iterator_type = typename sparse_set::iterator_type; using unchecked_type = std::array *, (sizeof...(Component) - 1)>; + using filter_type = std::array *, sizeof...(Exclude)>; class iterator { friend class basic_view, Component...>; - iterator(underlying_iterator_type first, underlying_iterator_type last, unchecked_type other, std::tuple *...> exclude) ENTT_NOEXCEPT + iterator(underlying_iterator_type first, underlying_iterator_type last, unchecked_type other, filter_type exclude) ENTT_NOEXCEPT : begin{first}, end{last}, unchecked{other}, @@ -97,7 +98,7 @@ class basic_view, Component...> { bool valid() const ENTT_NOEXCEPT { return std::all_of(unchecked.cbegin(), unchecked.cend(), [this](const sparse_set *view) { return view->has(*begin); }) - && (!std::get *>(filter)->has(*begin) && ...); + && std::none_of(filter.cbegin(), filter.cend(), [this](const sparse_set *view) { return view->has(*begin); }); } public: @@ -138,7 +139,7 @@ class basic_view, Component...> { underlying_iterator_type begin; underlying_iterator_type end; unchecked_type unchecked; - std::tuple *...> filter; + filter_type filter; }; // we could use pool_type *..., but vs complains about it and refuses to compile for unknown reasons (likely a bug) @@ -303,7 +304,8 @@ class basic_view, Component...> { */ iterator_type begin() const ENTT_NOEXCEPT { const auto *view = candidate(); - return iterator_type{view->begin(), view->end(), unchecked(view), filter}; + const filter_type exclude{std::get *>(filter)...}; + return iterator_type{view->begin(), view->end(), unchecked(view), exclude}; } /** @@ -323,7 +325,8 @@ class basic_view, Component...> { */ iterator_type end() const ENTT_NOEXCEPT { const auto *view = candidate(); - return iterator_type{view->end(), view->end(), unchecked(view), filter}; + const filter_type exclude{std::get *>(filter)...}; + return iterator_type{view->end(), view->end(), unchecked(view), exclude}; } /** @@ -334,7 +337,8 @@ class basic_view, Component...> { */ iterator_type find(const entity_type entt) const ENTT_NOEXCEPT { const auto *view = candidate(); - iterator_type it{view->find(entt), view->end(), unchecked(view), filter}; + const filter_type exclude{std::get *>(filter)...}; + iterator_type it{view->find(entt), view->end(), unchecked(view), exclude}; return (it != end() && *it == entt) ? it : end(); }