Browse Source

view: avoid moving the callback with multi-type views

Michele Caini 3 years ago
parent
commit
8b27a846a6
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/entt/entity/view.hpp

+ 4 - 4
src/entt/entity/view.hpp

@@ -220,7 +220,7 @@ class basic_view<get_t<Get...>, exclude_t<Exclude...>> {
     }
     }
 
 
     template<std::size_t Curr, typename Func, std::size_t... Index>
     template<std::size_t Curr, typename Func, std::size_t... Index>
-    void each(Func func, std::index_sequence<Index...>) const {
+    void each(Func &func, std::index_sequence<Index...>) const {
         for(const auto curr: storage<Curr>().each()) {
         for(const auto curr: storage<Curr>().each()) {
             if(const auto entt = std::get<0>(curr); ((sizeof...(Get) != 1u) || (entt != tombstone)) && ((Curr == Index || storage<Index>().contains(entt)) && ...) && !reject(entt)) {
             if(const auto entt = std::get<0>(curr); ((sizeof...(Get) != 1u) || (entt != tombstone)) && ((Curr == Index || storage<Index>().contains(entt)) && ...) && !reject(entt)) {
                 if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
                 if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
@@ -233,8 +233,8 @@ class basic_view<get_t<Get...>, exclude_t<Exclude...>> {
     }
     }
 
 
     template<typename Func, std::size_t... Index>
     template<typename Func, std::size_t... Index>
-    void pick_and_each(Func func, std::index_sequence<Index...> seq) const {
-        ((&storage<Index>() == view ? each<Index>(std::move(func), seq) : void()), ...);
+    void pick_and_each(Func &func, std::index_sequence<Index...> seq) const {
+        ((&storage<Index>() == view ? each<Index>(func, seq) : void()), ...);
     }
     }
 
 
 public:
 public:
@@ -487,7 +487,7 @@ public:
      */
      */
     template<typename Func>
     template<typename Func>
     void each(Func func) const {
     void each(Func func) const {
-        pick_and_each(std::move(func), std::index_sequence_for<Get...>{});
+        pick_and_each(func, std::index_sequence_for<Get...>{});
     }
     }
 
 
     /**
     /**