Procházet zdrojové kódy

view: avoid moving the callback with multi-type views

Michele Caini před 3 roky
rodič
revize
8b27a846a6
1 změnil soubory, kde provedl 4 přidání a 4 odebrání
  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>
-    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()) {
             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({})))>) {
@@ -233,8 +233,8 @@ class basic_view<get_t<Get...>, exclude_t<Exclude...>> {
     }
 
     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:
@@ -487,7 +487,7 @@ public:
      */
     template<typename Func>
     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...>{});
     }
 
     /**