From 8bd5605c2a34852c77f75bc755417da7be4df5c8 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 27 Apr 2018 23:19:08 +0200 Subject: [PATCH] now works also with VS2017 and GCC6 --- src/entt/entity/view.hpp | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index e5b49bb16..483eaf17e 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -429,28 +429,6 @@ class View final { using pattern_type = std::tuple &...>; using traits_type = entt_traits; - template - struct ComponentList {}; - - template, typename = void> - struct SplitComponentListBy; - - template - struct SplitComponentListBy, ComponentList, std::enable_if_t::value>> { - using pre_type = ComponentList; - using post_type = ComponentList; - }; - - template - struct SplitComponentListBy, ComponentList, std::enable_if_t::value>> - : SplitComponentListBy, ComponentList> {}; - - template - using PreList = typename SplitComponentListBy>::pre_type; - - template - using PostList = typename SplitComponentListBy>::post_type; - class Iterator { using size_type = typename view_type::size_type; @@ -526,8 +504,16 @@ class View final { reset(); } - template - void each(Func func, ComponentList, ComponentList) const { + template + inline std::enable_if_t::value, const Other &> + get(It &it, Entity) const { return *(it++); } + + template + inline std::enable_if_t::value, const Other &> + get(const It &, Entity entity) const { return std::get &>(pools).get(entity); } + + template + void each(Func func) const { const auto extent = std::min({ std::get &>(pools).extent()... }); auto &pool = std::get &>(pools); @@ -540,8 +526,8 @@ class View final { for(; pos && unchecked[pos-1]->fast(entity); --pos); if(!pos) { - // avoided indirections due to the sparse set for the pivot - func(entity, std::get &>(pools).get(entity)..., *(raw)++, std::get &>(pools).get(entity)...); + // avoided indirections due to the sparse set for the pivot (this-> required because of GCC 6) + func(entity, this->get(raw, entity)...); } } }); @@ -779,7 +765,7 @@ public: inline void each(Func func) const { constexpr auto indexes = ident; using accumulator_type = int[]; - accumulator_type accumulator = { (indexes.template get() == idx ? (each(std::move(func), PreList{}, PostList{}), 0) : 0)... }; + accumulator_type accumulator = { (indexes.template get() == idx ? (each(std::move(func)), 0) : 0)... }; (void)accumulator; }