From 5809b4aafae74072b7c54cc043aed509e54e690b Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 9 Dec 2022 20:09:56 +0330 Subject: [PATCH] AK: Let HashMap also take a ValueTraits We were previously using Traits, take that frrom the template parameters instead. This is needed by the Jakt runtime. --- AK/Forward.h | 6 +++--- AK/HashMap.h | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AK/Forward.h b/AK/Forward.h index d3987b9377e..86b288a3181 100644 --- a/AK/Forward.h +++ b/AK/Forward.h @@ -80,11 +80,11 @@ class HashTable; template> using OrderedHashTable = HashTable; -template, bool IsOrdered = false> +template, typename ValueTraits = Traits, bool IsOrdered = false> class HashMap; -template> -using OrderedHashMap = HashMap; +template, typename ValueTraits = Traits> +using OrderedHashMap = HashMap; template class Badge; diff --git a/AK/HashMap.h b/AK/HashMap.h index 24f37b0d0ae..2a036cc5ae1 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -13,7 +13,7 @@ namespace AK { -template +template class HashMap { private: struct Entry { @@ -126,8 +126,8 @@ public: ErrorOr try_ensure_capacity(size_t capacity) { return m_table.try_ensure_capacity(capacity); } - Optional::ConstPeekType> get(K const& key) const - requires(!IsPointer::PeekType>) + Optional get(K const& key) const + requires(!IsPointer) { auto it = find(key); if (it == end()) @@ -135,8 +135,8 @@ public: return (*it).value; } - Optional::ConstPeekType> get(K const& key) const - requires(IsPointer::PeekType>) + Optional get(K const& key) const + requires(IsPointer) { auto it = find(key); if (it == end()) @@ -144,8 +144,8 @@ public: return (*it).value; } - Optional::PeekType> get(K const& key) - requires(!IsConst::PeekType>) + Optional get(K const& key) + requires(!IsConst) { auto it = find(key); if (it == end()) @@ -154,9 +154,9 @@ public: } template Key> - requires(IsSame>) Optional::PeekType> get(Key const& key) + requires(IsSame>) Optional get(Key const& key) const - requires(!IsPointer::PeekType>) + requires(!IsPointer) { auto it = find(key); if (it == end()) @@ -165,9 +165,9 @@ public: } template Key> - requires(IsSame>) Optional::ConstPeekType> get(Key const& key) + requires(IsSame>) Optional get(Key const& key) const - requires(IsPointer::PeekType>) + requires(IsPointer) { auto it = find(key); if (it == end()) @@ -176,8 +176,8 @@ public: } template Key> - requires(IsSame>) Optional::PeekType> get(Key const& key) - requires(!IsConst::PeekType>) + requires(IsSame>) Optional get(Key const& key) + requires(!IsConst) { auto it = find(key); if (it == end())