Ver código fonte

table: swap based move assignment operator

Michele Caini 1 ano atrás
pai
commit
d40e5f3dd5
2 arquivos alterados com 2 adições e 2 exclusões
  1. 1 1
      src/entt/container/table.hpp
  2. 1 1
      test/entt/container/table.cpp

+ 1 - 1
src/entt/container/table.hpp

@@ -252,7 +252,7 @@ public:
      * @return This container.
      * @return This container.
      */
      */
     basic_table &operator=(basic_table &&other) noexcept {
     basic_table &operator=(basic_table &&other) noexcept {
-        payload = std::move(other.payload);
+        swap(other);
         return *this;
         return *this;
     }
     }
 
 

+ 1 - 1
test/entt/container/table.cpp

@@ -90,7 +90,7 @@ TEST(Table, Move) {
     other = std::move(table);
     other = std::move(table);
     test::is_initialized(table);
     test::is_initialized(table);
 
 
-    ASSERT_TRUE(table.empty());
+    ASSERT_FALSE(table.empty());
     ASSERT_FALSE(other.empty());
     ASSERT_FALSE(other.empty());
 
 
     ASSERT_EQ(other[0u], std::make_tuple(3, 'c'));
     ASSERT_EQ(other[0u], std::make_tuple(3, 'c'));