From eb285643ed5dab8125e9c6bc94abd7ef562096a5 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 27 Feb 2025 23:58:57 +0100 Subject: Finish work on deducing this, for now --- asl/containers/hash_map.hpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'asl/containers/hash_map.hpp') diff --git a/asl/containers/hash_map.hpp b/asl/containers/hash_map.hpp index 104bd6a..a59e580 100644 --- a/asl/containers/hash_map.hpp +++ b/asl/containers/hash_map.hpp @@ -147,31 +147,18 @@ public: // NOLINTEND(*-pointer-arithmetic) } - // @Todo(C++23) Deducing this template - requires key_hasher && key_comparator - const V* get(const U& value) const + auto get(this auto&& self, const U& value) + requires key_hasher && key_comparator { - isize_t index = Base::find_slot_lookup(value); + using return_type = un_ref_t>*; + isize_t index = self.find_slot_lookup(value); if (index >= 0) { // NOLINTNEXTLINE(*-pointer-arithmetic) - return &Base::m_values[index].as_init_unsafe().value; + return return_type{ &self.m_values[index].as_init_unsafe().value }; } - return nullptr; - } - - template - requires key_hasher && key_comparator - V* get(const U& value) - { - 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; + return return_type{ nullptr }; } }; -- cgit