wip
This commit is contained in:
parent
f9358ed031
commit
1037256a30
@ -63,14 +63,42 @@ template <typename T, size_t MinItemsInBlock = 1024> class PoolAllocator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolAllocator(const PoolAllocator &) {}
|
PoolAllocator(const PoolAllocator &) = delete;
|
||||||
|
PoolAllocator &operator=(const PoolAllocator &) = delete;
|
||||||
|
|
||||||
PoolAllocator &operator=(const PoolAllocator &){return *this;}
|
PoolAllocator(PoolAllocator &&other) noexcept
|
||||||
|
: free_lists_(std::move(other.free_lists_)),
|
||||||
|
blocks_(std::move(other.blocks_)),
|
||||||
|
current_block_ptr_(other.current_block_ptr_),
|
||||||
|
current_block_left_items_(other.current_block_left_items_),
|
||||||
|
total_allocated_(other.total_allocated_)
|
||||||
|
{
|
||||||
|
other.current_block_ptr_ = nullptr;
|
||||||
|
other.current_block_left_items_ = 0;
|
||||||
|
other.total_allocated_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// You may also want to implement move semantics if needed
|
PoolAllocator &operator=(PoolAllocator &&other) noexcept
|
||||||
PoolAllocator(PoolAllocator &&) noexcept = default;
|
{
|
||||||
PoolAllocator &operator=(PoolAllocator &&) noexcept = default;
|
if (this != &other)
|
||||||
|
{
|
||||||
|
for (auto block : blocks_)
|
||||||
|
{
|
||||||
|
std::free(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
free_lists_ = std::move(other.free_lists_);
|
||||||
|
blocks_ = std::move(other.blocks_);
|
||||||
|
current_block_ptr_ = other.current_block_ptr_;
|
||||||
|
current_block_left_items_ = other.current_block_left_items_;
|
||||||
|
total_allocated_ = other.total_allocated_;
|
||||||
|
|
||||||
|
other.current_block_ptr_ = nullptr;
|
||||||
|
other.current_block_left_items_ = 0;
|
||||||
|
other.total_allocated_ = 0;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t get_next_power_of_two_exponent(size_t n) const
|
size_t get_next_power_of_two_exponent(size_t n) const
|
||||||
|
Loading…
Reference in New Issue
Block a user