From 5f93560cbde08167041d701151d3a24cd5348e32 Mon Sep 17 00:00:00 2001 From: freshFruict <75492585+freshFruict@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:23:36 +0300 Subject: [PATCH] hash_storage: fix assignment operator (#211) The assignment operator of hash_storage now calls the `clear` function to ensure proper behavior. Previously, it only cleared the destination hash_storage if the source hash_storage was empty, leading to keys being left in the destination hash_storage that did not exist in the source, and not being copied if they already exist in the destination hash_storage. Now, the assignment operator clears the destination hash_storage every time, preventing this issue. Co-authored-by: VirtualDeep <75492585+VirtualDeep@users.noreply.github.com> --- include/cista/containers/hash_storage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cista/containers/hash_storage.h b/include/cista/containers/hash_storage.h index b094b5d6..ab6d3845 100644 --- a/include/cista/containers/hash_storage.h +++ b/include/cista/containers/hash_storage.h @@ -292,8 +292,8 @@ struct hash_storage { } hash_storage& operator=(hash_storage const& other) { + clear(); if (other.size() == 0U) { - clear(); return *this; } for (const auto& v : other) {