storage: free memory in move assignment operator (with tests)
This commit is contained in:
@@ -314,11 +314,14 @@ public:
|
||||
* @return This sparse set.
|
||||
*/
|
||||
basic_storage & operator=(basic_storage &&other) ENTT_NOEXCEPT {
|
||||
maybe_resize_packed(0u);
|
||||
|
||||
allocator = std::move(other.allocator);
|
||||
bucket_allocator = std::move(other.bucket_allocator);
|
||||
packed = std::exchange(other.packed, bucket_alloc_pointer{});
|
||||
bucket = std::exchange(other.bucket, 0u);
|
||||
count = std::exchange(other.count, 0u);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,16 @@ TEST(Storage, Functionalities) {
|
||||
|
||||
ASSERT_EQ(pool.capacity(), 0u);
|
||||
|
||||
(void)entt::storage<int>{std::move(pool)};
|
||||
entt::storage<int> other;
|
||||
entt::storage<int> other{std::move(pool)};
|
||||
|
||||
pool = std::move(other);
|
||||
|
||||
other = entt::storage<int>{};
|
||||
other.emplace(entt::entity{3}, 3);
|
||||
other = std::move(pool);
|
||||
|
||||
ASSERT_EQ(pool.capacity(), 0u);
|
||||
ASSERT_EQ(other.capacity(), 0u);
|
||||
}
|
||||
|
||||
TEST(Storage, EmptyType) {
|
||||
|
||||
Reference in New Issue
Block a user