diff options
Diffstat (limited to 'asl/hash_map.hpp')
-rw-r--r-- | asl/hash_map.hpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/asl/hash_map.hpp b/asl/hash_map.hpp index 300ffdb..93f93e7 100644 --- a/asl/hash_map.hpp +++ b/asl/hash_map.hpp @@ -147,9 +147,23 @@ public: // NOLINTEND(*-pointer-arithmetic)
}
+ // @Todo(C++23) Deducing this
template<typename U>
requires key_hasher<KeyHasher, U> && key_comparator<KeyComparator, K, U>
- V* get(const U& value) const
+ const V* get(const U& value) const
+ {
+ isize_t index = Base::find_slot_lookup(value);
+ if (index >= 0)
+ {
+ // NOLINTNEXTLINE(*-pointer-arithmetic)
+ return &Base::m_values[index].as_init_unsafe().value;
+ }
+ return nullptr;
+ }
+
+ template<typename U>
+ requires key_hasher<KeyHasher, U> && key_comparator<KeyComparator, K, U>
+ V* get(const U& value)
{
isize_t index = Base::find_slot_lookup(value);
if (index >= 0)
|