forked from boostorg/unordered
Use const_key_type internally
This commit is contained in:
@ -2473,7 +2473,7 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
typedef typename Types::bucket bucket;
|
||||
typedef typename Types::hasher hasher;
|
||||
typedef typename Types::key_equal key_equal;
|
||||
typedef typename Types::key_type key_type;
|
||||
typedef typename Types::const_key_type const_key_type;
|
||||
typedef typename Types::extractor extractor;
|
||||
typedef typename Types::value_type value_type;
|
||||
typedef typename Types::table table_impl;
|
||||
@ -3035,12 +3035,12 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
|
||||
// Accessors
|
||||
|
||||
key_type const& get_key(value_type const& x) const
|
||||
const_key_type& get_key(value_type const& x) const
|
||||
{
|
||||
return extractor::extract(x);
|
||||
}
|
||||
|
||||
std::size_t hash(key_type const& k) const
|
||||
std::size_t hash(const_key_type& k) const
|
||||
{
|
||||
return policy::apply_hash(this->hash_function(), k);
|
||||
}
|
||||
@ -3055,13 +3055,13 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
policy::apply_hash(hf, k), k, eq);
|
||||
}
|
||||
|
||||
node_pointer find_node(std::size_t key_hash, key_type const& k) const
|
||||
node_pointer find_node(std::size_t key_hash, const_key_type& k) const
|
||||
{
|
||||
return static_cast<table_impl const*>(this)->find_node_impl(
|
||||
key_hash, k, this->key_eq());
|
||||
}
|
||||
|
||||
node_pointer find_node(key_type const& k) const
|
||||
node_pointer find_node(const_key_type& k) const
|
||||
{
|
||||
return static_cast<table_impl const*>(this)->find_node_impl(
|
||||
hash(k), k, this->key_eq());
|
||||
@ -3379,7 +3379,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
typedef typename table::link_pointer link_pointer;
|
||||
typedef typename table::hasher hasher;
|
||||
typedef typename table::key_equal key_equal;
|
||||
typedef typename table::key_type key_type;
|
||||
typedef typename table::const_key_type const_key_type;
|
||||
typedef typename table::node_constructor node_constructor;
|
||||
typedef typename table::node_tmp node_tmp;
|
||||
typedef typename table::extractor extractor;
|
||||
@ -3453,12 +3453,12 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t count(key_type const& k) const
|
||||
std::size_t count(const_key_type& k) const
|
||||
{
|
||||
return this->find_node(k) ? 1 : 0;
|
||||
}
|
||||
|
||||
value_type& at(key_type const& k) const
|
||||
value_type& at(const_key_type& k) const
|
||||
{
|
||||
if (this->size_) {
|
||||
node_pointer n = this->find_node(k);
|
||||
@ -3470,7 +3470,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
std::out_of_range("Unable to find key in unordered_map."));
|
||||
}
|
||||
|
||||
std::pair<iterator, iterator> equal_range(key_type const& k) const
|
||||
std::pair<iterator, iterator> equal_range(const_key_type& k) const
|
||||
{
|
||||
node_pointer n = this->find_node(k);
|
||||
return std::make_pair(iterator(n), iterator(n ? next_node(n) : n));
|
||||
@ -3530,7 +3530,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
return this->add_node(b.release(), key_hash);
|
||||
}
|
||||
|
||||
value_type& operator[](key_type const& k)
|
||||
value_type& operator[](const_key_type& k)
|
||||
{
|
||||
std::size_t key_hash = this->hash(k);
|
||||
node_pointer pos = this->find_node(key_hash, k);
|
||||
@ -3623,7 +3623,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
|
||||
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||
iterator emplace_hint_impl(
|
||||
c_iterator hint, key_type const& k, BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
c_iterator hint, const_key_type& k, BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
{
|
||||
if (hint.node_ && this->key_eq()(k, this->get_key(*hint))) {
|
||||
return iterator(hint.node_);
|
||||
@ -3633,7 +3633,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
}
|
||||
|
||||
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||
emplace_return emplace_impl(key_type const& k, BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
emplace_return emplace_impl(const_key_type& k, BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
{
|
||||
std::size_t key_hash = this->hash(k);
|
||||
node_pointer pos = this->find_node(key_hash, k);
|
||||
@ -3656,7 +3656,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
node_tmp b(boost::unordered::detail::func::construct_node_from_args(
|
||||
this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD),
|
||||
this->node_alloc());
|
||||
key_type const& k = this->get_key(b.node_->value());
|
||||
const_key_type& k = this->get_key(b.node_->value());
|
||||
if (hint.node_ && this->key_eq()(k, this->get_key(*hint))) {
|
||||
return iterator(hint.node_);
|
||||
}
|
||||
@ -3675,7 +3675,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
node_tmp b(boost::unordered::detail::func::construct_node_from_args(
|
||||
this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD),
|
||||
this->node_alloc());
|
||||
key_type const& k = this->get_key(b.node_->value());
|
||||
const_key_type& k = this->get_key(b.node_->value());
|
||||
std::size_t key_hash = this->hash(k);
|
||||
node_pointer pos = this->find_node(key_hash, k);
|
||||
if (pos) {
|
||||
@ -3700,7 +3700,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
}
|
||||
|
||||
template <class InputIt>
|
||||
void insert_range_impl(key_type const& k, InputIt i, InputIt j)
|
||||
void insert_range_impl(const_key_type& k, InputIt i, InputIt j)
|
||||
{
|
||||
insert_range_impl2(k, i, j);
|
||||
|
||||
@ -3718,7 +3718,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
}
|
||||
|
||||
template <class InputIt>
|
||||
void insert_range_impl2(key_type const& k, InputIt i, InputIt j)
|
||||
void insert_range_impl2(const_key_type& k, InputIt i, InputIt j)
|
||||
{
|
||||
// No side effects in this initial code
|
||||
std::size_t key_hash = this->hash(k);
|
||||
@ -3748,7 +3748,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
a.alloc_, a.node_->value_ptr(), *i);
|
||||
node_tmp b(a.release(), a.alloc_);
|
||||
|
||||
key_type const& k = this->get_key(b.node_->value());
|
||||
const_key_type& k = this->get_key(b.node_->value());
|
||||
std::size_t key_hash = this->hash(k);
|
||||
node_pointer pos = this->find_node(key_hash, k);
|
||||
|
||||
@ -3768,7 +3768,7 @@ struct table_impl : boost::unordered::detail::table<Types>
|
||||
//
|
||||
// no throw
|
||||
|
||||
std::size_t erase_key(key_type const& k)
|
||||
std::size_t erase_key(const_key_type& k)
|
||||
{
|
||||
if (!this->size_)
|
||||
return 0;
|
||||
@ -4012,7 +4012,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
typedef typename table::link_pointer link_pointer;
|
||||
typedef typename table::hasher hasher;
|
||||
typedef typename table::key_equal key_equal;
|
||||
typedef typename table::key_type key_type;
|
||||
typedef typename table::const_key_type const_key_type;
|
||||
typedef typename table::node_constructor node_constructor;
|
||||
typedef typename table::node_tmp node_tmp;
|
||||
typedef typename table::extractor extractor;
|
||||
@ -4091,7 +4091,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t count(key_type const& k) const
|
||||
std::size_t count(const_key_type& k) const
|
||||
{
|
||||
node_pointer n = this->find_node(k);
|
||||
if (!n)
|
||||
@ -4107,7 +4107,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
return x;
|
||||
}
|
||||
|
||||
std::pair<iterator, iterator> equal_range(key_type const& k) const
|
||||
std::pair<iterator, iterator> equal_range(const_key_type& k) const
|
||||
{
|
||||
node_pointer n = this->find_node(k);
|
||||
return std::make_pair(iterator(n), iterator(n ? next_group(n) : n));
|
||||
@ -4315,7 +4315,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
iterator emplace_impl(node_pointer n)
|
||||
{
|
||||
node_tmp a(n, this->node_alloc());
|
||||
key_type const& k = this->get_key(a.node_->value());
|
||||
const_key_type& k = this->get_key(a.node_->value());
|
||||
std::size_t key_hash = this->hash(k);
|
||||
node_pointer position = this->find_node(key_hash, k);
|
||||
this->reserve_for_insert(this->size_ + 1);
|
||||
@ -4325,7 +4325,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
iterator emplace_hint_impl(c_iterator hint, node_pointer n)
|
||||
{
|
||||
node_tmp a(n, this->node_alloc());
|
||||
key_type const& k = this->get_key(a.node_->value());
|
||||
const_key_type& k = this->get_key(a.node_->value());
|
||||
if (hint.node_ && this->key_eq()(k, this->get_key(*hint))) {
|
||||
this->reserve_for_insert(this->size_ + 1);
|
||||
return iterator(this->add_using_hint(a.release(), hint.node_));
|
||||
@ -4340,7 +4340,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
void emplace_impl_no_rehash(node_pointer n)
|
||||
{
|
||||
node_tmp a(n, this->node_alloc());
|
||||
key_type const& k = this->get_key(a.node_->value());
|
||||
const_key_type& k = this->get_key(a.node_->value());
|
||||
std::size_t key_hash = this->hash(k);
|
||||
node_pointer position = this->find_node(key_hash, k);
|
||||
this->add_node(a.release(), key_hash, position);
|
||||
@ -4391,7 +4391,7 @@ struct grouped_table_impl : boost::unordered::detail::table<Types>
|
||||
//
|
||||
// no throw
|
||||
|
||||
std::size_t erase_key(key_type const& k)
|
||||
std::size_t erase_key(const_key_type& k)
|
||||
{
|
||||
if (!this->size_)
|
||||
return 0;
|
||||
|
@ -16,7 +16,7 @@ template <typename A, typename K, typename M, typename H, typename P> struct map
|
||||
typedef std::pair<K const, M> value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef K key_type;
|
||||
typedef K const const_key_type;
|
||||
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
@ -29,8 +29,7 @@ template <typename A, typename K, typename M, typename H, typename P> struct map
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
|
||||
typedef boost::unordered::detail::table_impl<types> table;
|
||||
typedef boost::unordered::detail::map_extractor<key_type, value_type>
|
||||
extractor;
|
||||
typedef boost::unordered::detail::map_extractor<K, value_type> extractor;
|
||||
|
||||
typedef typename boost::unordered::detail::pick_policy<K>::type policy;
|
||||
|
||||
@ -50,7 +49,7 @@ struct multimap
|
||||
typedef std::pair<K const, M> value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef K key_type;
|
||||
typedef K const const_key_type;
|
||||
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
@ -63,8 +62,7 @@ struct multimap
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
|
||||
typedef boost::unordered::detail::grouped_table_impl<types> table;
|
||||
typedef boost::unordered::detail::map_extractor<key_type, value_type>
|
||||
extractor;
|
||||
typedef boost::unordered::detail::map_extractor<K, value_type> extractor;
|
||||
|
||||
typedef typename boost::unordered::detail::pick_policy<K>::type policy;
|
||||
|
||||
|
@ -16,7 +16,7 @@ template <typename A, typename T, typename H, typename P> struct set
|
||||
typedef T value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef T key_type;
|
||||
typedef T const const_key_type;
|
||||
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
@ -48,7 +48,7 @@ template <typename A, typename T, typename H, typename P> struct multiset
|
||||
typedef T value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef T key_type;
|
||||
typedef T const const_key_type;
|
||||
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
|
Reference in New Issue
Block a user