Browse Source

fix(hash_map): make find() const compatible

greatbridf 2 years ago
parent
commit
789d002b13
1 changed files with 3 additions and 3 deletions
  1. 3 3
      include/types/hash_map.hpp

+ 3 - 3
include/types/hash_map.hpp

@@ -260,9 +260,9 @@ public:
     {
         auto hash_value = _Hasher::hash(key, hash_length());
         const auto& bucket = buckets.at(hash_value);
-        for (const auto& item : bucket) {
-            if (key == item.key)
-                return const_iterator_type(&(*item));
+        for (auto iter = bucket.cbegin(); iter != bucket.cend(); ++iter) {
+            if (key == iter->key)
+                return const_iterator_type(&iter);
         }
         return const_iterator_type(nullptr);
     }