From 03edf7f4a8a8e1e77349bdf37154297aa57d9b83 Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Thu, 2 Dec 2021 15:30:17 -0800 Subject: [PATCH] Add member function template `find_previous_node_impl` so it can be used in heterogenous contexts --- include/boost/unordered/detail/implementation.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index daf9b8f6..eb11219b 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -3618,9 +3618,9 @@ namespace boost { } } - // Find the node before the key, so that it can be erased. - link_pointer find_previous_node( - const_key_type& k, std::size_t bucket_index) + template + link_pointer find_previous_node_impl( + KeyEqual const& eq, Key const& k, std::size_t const bucket_index) { link_pointer prev = this->get_previous_start(bucket_index); if (!prev) { @@ -3634,7 +3634,7 @@ namespace boost { } else if (n->is_first_in_group()) { if (node_bucket(n) != bucket_index) { return link_pointer(); - } else if (this->key_eq()(k, this->get_key(n))) { + } else if (eq(k, this->get_key(n))) { return prev; } } @@ -3642,6 +3642,13 @@ namespace boost { } } + // Find the node before the key, so that it can be erased. + link_pointer find_previous_node( + const_key_type& k, std::size_t bucket_index) + { + return find_previous_node_impl(this->key_eq(), k, bucket_index); + } + // Extract and erase inline node_pointer extract_by_key(const_key_type& k)