From 183644d46f871b48ffe442e53a3c567465f0c5e1 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 24 Aug 2023 17:32:33 +0300 Subject: [PATCH] Add proper util::hash_table move constructor & assignment --- libs/util/include/psemek/util/hash_table.hpp | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libs/util/include/psemek/util/hash_table.hpp b/libs/util/include/psemek/util/hash_table.hpp index af9cf130..ba9f9937 100644 --- a/libs/util/include/psemek/util/hash_table.hpp +++ b/libs/util/include/psemek/util/hash_table.hpp @@ -115,6 +115,27 @@ namespace psemek::util , Equal(std::forward(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; }