Skip to content

Commit

Permalink
workaround for an issue with clang 6
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Sep 18, 2019
1 parent 90eeeed commit 3f96e04
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/entt/entity/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {

using underlying_iterator_type = typename sparse_set<Entity>::iterator_type;
using unchecked_type = std::array<const sparse_set<Entity> *, (sizeof...(Component) - 1)>;
using filter_type = std::array<const sparse_set<Entity> *, sizeof...(Exclude)>;

class iterator {
friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;

iterator(underlying_iterator_type first, underlying_iterator_type last, unchecked_type other, std::tuple<pool_type<Exclude> *...> 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},
Expand All @@ -97,7 +98,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {

bool valid() const ENTT_NOEXCEPT {
return std::all_of(unchecked.cbegin(), unchecked.cend(), [this](const sparse_set<Entity> *view) { return view->has(*begin); })
&& (!std::get<pool_type<Exclude> *>(filter)->has(*begin) && ...);
&& std::none_of(filter.cbegin(), filter.cend(), [this](const sparse_set<Entity> *view) { return view->has(*begin); });
}

public:
Expand Down Expand Up @@ -138,7 +139,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
underlying_iterator_type begin;
underlying_iterator_type end;
unchecked_type unchecked;
std::tuple<pool_type<Exclude> *...> filter;
filter_type filter;
};

// we could use pool_type<Component> *..., but vs complains about it and refuses to compile for unknown reasons (likely a bug)
Expand Down Expand Up @@ -303,7 +304,8 @@ class basic_view<Entity, exclude_t<Exclude...>, 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<pool_type<Exclude> *>(filter)...};
return iterator_type{view->begin(), view->end(), unchecked(view), exclude};
}

/**
Expand All @@ -323,7 +325,8 @@ class basic_view<Entity, exclude_t<Exclude...>, 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<pool_type<Exclude> *>(filter)...};
return iterator_type{view->end(), view->end(), unchecked(view), exclude};
}

/**
Expand All @@ -334,7 +337,8 @@ class basic_view<Entity, exclude_t<Exclude...>, 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<pool_type<Exclude> *>(filter)...};
iterator_type it{view->find(entt), view->end(), unchecked(view), exclude};
return (it != end() && *it == entt) ? it : end();
}

Expand Down

0 comments on commit 3f96e04

Please sign in to comment.