Get initial prototype of transparent count() working

This commit is contained in:
LeonineKing1199
2021-11-19 15:29:57 -08:00
parent c8abaf32ee
commit f41b3e8295
3 changed files with 82 additions and 0 deletions

View File

@@ -757,6 +757,8 @@ namespace boost {
size_type count(const key_type&) const;
template <class TransparentKey> size_type count(const TransparentKey&) const;
std::pair<iterator, iterator> equal_range(const key_type&);
std::pair<const_iterator, const_iterator> equal_range(
const key_type&) const;
@@ -1837,6 +1839,21 @@ namespace boost {
return table_.find_node(k) ? 1 : 0;
}
template <class K, class T, class H, class P, class A>
template <class TransparentKey>
typename unordered_map<K, T, H, P, A>::size_type
unordered_map<K, T, H, P, A>::count(const TransparentKey& k) const
{
std::size_t const key_hash =
table::policy::apply_hash(this->hash_function(), k);
P const& eq = this->key_eq();
node_pointer p = table_.find_node_impl(key_hash, k, eq);
return (p ? 1 : 0);
}
template <class K, class T, class H, class P, class A>
std::pair<typename unordered_map<K, T, H, P, A>::iterator,
typename unordered_map<K, T, H, P, A>::iterator>