From 850a1f91552958b0e3f2bb5a4807d5c41ecc1e2c Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 7 May 2019 23:19:09 +0200 Subject: [PATCH] workaround for a bug in GCC7 --- src/entt/entity/view.hpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index d7920fedf..3b15bc783 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -64,6 +64,9 @@ class basic_view { template using pool_type = std::conditional_t, const storage>, storage>; + template + using component_iterator_type = decltype(std::declval>().begin()); + using underlying_iterator_type = typename sparse_set::iterator_type; using unchecked_type = std::array *, (sizeof...(Component) - 1)>; using traits_type = entt_traits; @@ -158,30 +161,18 @@ class basic_view { } template - void each(std::tuple pack, Func func) const { + void each(std::tuple, Other *...> pack, Func func) const { const auto end = std::get *>(pools)->sparse_set::end(); auto begin = std::get *>(pools)->sparse_set::begin(); std::for_each(begin, end, [&pack, &func, raw = std::get *>(pools)->begin(), this](const auto entity) mutable { - auto curr = raw++; + std::get>(pack) = raw++; if(((std::get(pack) = std::get *>(pools)->try_get(entity)) && ...)) { if constexpr(std::is_invocable_v...>) { - func([&pack, &curr]() -> decltype(auto) { - if constexpr(std::is_same_v) { - return *curr; - } else { - return *std::get(pack); - } - }()...); + func(*std::get, component_iterator_type, Component *>>(pack)...); } else { - func(entity, [&pack, &curr]() -> decltype(auto) { - if constexpr(std::is_same_v) { - return *curr; - } else { - return *std::get(pack); - } - }()...); + func(entity, *std::get, component_iterator_type, Component *>>(pack)...); } } }); @@ -415,7 +406,7 @@ public: */ template inline void each(Func func) const { - each(std::tuple_cat(std::conditional_t, std::tuple<>, std::tuple>{}...), std::move(func)); + each(std::tuple_cat(std::tuple>{}, std::conditional_t, std::tuple<>, std::tuple>{}...), std::move(func)); } private: