1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:47:46 +00:00

AK: Rewrite HashMap::clone signature with template-args and const

This commit is contained in:
Ben Wiederhake 2023-05-13 20:25:22 +02:00 committed by Jelle Raaijmakers
parent dabc6dd962
commit 6421899078
2 changed files with 79 additions and 2 deletions

View file

@ -281,9 +281,10 @@ public:
return hash;
}
ErrorOr<HashMap<K, V>> clone()
template<typename NewKeyTraits = KeyTraits, typename NewValueTraits = ValueTraits, bool NewIsOrdered = IsOrdered>
ErrorOr<HashMap<K, V, NewKeyTraits, NewValueTraits, NewIsOrdered>> clone() const
{
HashMap<K, V> hash_map_clone;
HashMap<K, V, NewKeyTraits, NewValueTraits, NewIsOrdered> hash_map_clone;
for (auto& it : *this)
TRY(hash_map_clone.try_set(it.key, it.value));
return hash_map_clone;