Add proper util::hash_table move constructor & assignment
This commit is contained in:
parent
8adfe7320b
commit
183644d46f
1 changed files with 21 additions and 0 deletions
|
|
@ -115,6 +115,27 @@ namespace psemek::util
|
|||
, Equal(std::forward<K>(k))
|
||||
{}
|
||||
|
||||
hash_table_impl(hash_table_impl && other)
|
||||
: Hash(std::move(other.hash()))
|
||||
, Equal(std::move(other.equal()))
|
||||
, storage_(std::move(other.storage_))
|
||||
{
|
||||
other.storage_.capacity = 0;
|
||||
other.size_ = 0;
|
||||
}
|
||||
|
||||
hash_table_impl & operator = (hash_table_impl && other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
storage_ = std::move(other.storage_);
|
||||
size_ = other.size_;
|
||||
other.storage_.capacity = 0;
|
||||
other.size_ = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Hash const & hash() const { return *this; }
|
||||
Equal const & equal() const { return *this; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue