Missing rvalue overload of at

This commit is contained in:
Daniel James
2017-04-20 22:59:00 +01:00
parent fedf533699
commit de5373413b
2 changed files with 9 additions and 0 deletions

View File

@ -729,6 +729,7 @@ template <class K, class T, class H, class P, class A> class unordered_map
const key_type&) const;
mapped_type& operator[](const key_type&);
mapped_type& operator[](BOOST_RV_REF(key_type));
mapped_type& at(const key_type&);
mapped_type const& at(const key_type&) const;
@ -1627,6 +1628,13 @@ typename unordered_map<K, T, H, P, A>::mapped_type&
return table_.try_emplace_impl(k).first->second;
}
template <class K, class T, class H, class P, class A>
typename unordered_map<K, T, H, P, A>::mapped_type&
unordered_map<K, T, H, P, A>::operator[](BOOST_RV_REF(key_type) k)
{
return table_.try_emplace_impl(boost::move(k)).first->second;
}
template <class K, class T, class H, class P, class A>
typename unordered_map<K, T, H, P, A>::mapped_type&
unordered_map<K, T, H, P, A>::at(const key_type& k)

View File

@ -422,6 +422,7 @@ void unordered_map_functions(X&, Key const& k, T const& v)
X a;
test::check_return_type<mapped_type>::equals_ref(a[k]);
test::check_return_type<mapped_type>::equals_ref(a[rvalue(k)]);
test::check_return_type<mapped_type>::equals_ref(a.at(k));
test::check_return_type<std::pair<iterator, bool> >::equals(
a.try_emplace(k, v));