From de5373413be4f2b7f005dfcbb0cee6f6d72d0d2b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 20 Apr 2017 22:59:00 +0100 Subject: [PATCH] Missing rvalue overload of at --- include/boost/unordered/unordered_map.hpp | 8 ++++++++ test/unordered/compile_tests.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 7b2ff6fc..f40d03d4 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -729,6 +729,7 @@ template 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::mapped_type& return table_.try_emplace_impl(k).first->second; } +template +typename unordered_map::mapped_type& + unordered_map::operator[](BOOST_RV_REF(key_type) k) +{ + return table_.try_emplace_impl(boost::move(k)).first->second; +} + template typename unordered_map::mapped_type& unordered_map::at(const key_type& k) diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index c676f2d5..12759c16 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -422,6 +422,7 @@ void unordered_map_functions(X&, Key const& k, T const& v) X a; test::check_return_type::equals_ref(a[k]); + test::check_return_type::equals_ref(a[rvalue(k)]); test::check_return_type::equals_ref(a.at(k)); test::check_return_type >::equals( a.try_emplace(k, v));