Browse Source

storage: safe self-move to support standard containers (close #601)

Michele Caini 5 years ago
parent
commit
9d687c25b3
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/entt/entity/storage.hpp

+ 3 - 2
src/entt/entity/storage.hpp

@@ -169,7 +169,8 @@ class basic_storage: public basic_sparse_set<Entity> {
     }
     }
 
 
     void swap_and_pop(const std::size_t pos) final {
     void swap_and_pop(const std::size_t pos) final {
-        instances[pos] = std::move(instances.back());
+        auto other = std::move(instances.back());
+        instances[pos] = std::move(other);
         instances.pop_back();
         instances.pop_back();
     }
     }
 
 
@@ -466,7 +467,7 @@ public:
 
 
     /**
     /**
      * @brief Sort all elements according to the given comparison function.
      * @brief Sort all elements according to the given comparison function.
-     * 
+     *
      * @sa sort_n
      * @sa sort_n
      *
      *
      * @tparam Compare Type of comparison function object.
      * @tparam Compare Type of comparison function object.