From a26e1c0f417f216183bdbe4cf21fa542290f70c4 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Tue, 11 Jan 2022 09:40:47 -0800 Subject: [PATCH] Implement `unordered_map::contains()` --- include/boost/unordered/unordered_map.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index f5d59c19..a7765fe7 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -796,6 +796,23 @@ namespace boost { const_iterator find(CompatibleKey const&, CompatibleHash const&, CompatiblePredicate const&) const; + bool contains(const key_type& k) const + { + return table_.find_node_impl( + table::policy::apply_hash(this->hash_function(), k), k, + this->key_eq()); + } + + template + typename boost::enable_if_c::value, + bool>::type + contains(const Key& k) const + { + return table_.find_node_impl( + table::policy::apply_hash(this->hash_function(), k), k, + this->key_eq()); + } + size_type count(const key_type&) const; template