diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index a753a45..2c7ce04 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -1175,8 +1175,9 @@ class flat_tree !dtl::is_convertible::value && //not convertible to iterator !dtl::is_convertible::value //not convertible to const_iterator , size_type>::type - erase(const K& k) + erase(BOOST_FWD_REF(K) key) { + const typename remove_cvref::type & k = key; //Support emulated rvalue references std::pair itp = this->equal_range(k); size_type ret = static_cast(itp.second - itp.first); if (ret) { diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp index fc61af7..e762634 100644 --- a/include/boost/container/detail/tree.hpp +++ b/include/boost/container/detail/tree.hpp @@ -1152,8 +1152,11 @@ class tree !dtl::is_convertible::value && //not convertible to iterator !dtl::is_convertible::value //not convertible to const_iterator , size_type>::type - erase(const K& k) - { return AllocHolder::erase_key(k, KeyNodeCompare(key_comp()), alloc_version()); } + erase(BOOST_FWD_REF(K) key) + { + const typename remove_cvref::type & k = key; //Support emulated rvalue references + return AllocHolder::erase_key(k, KeyNodeCompare(key_comp()), alloc_version()); + } template inline typename dtl::enable_if_c< diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp index 0879079..8df40ef 100644 --- a/include/boost/container/flat_map.hpp +++ b/include/boost/container/flat_map.hpp @@ -1333,7 +1333,7 @@ class flat_map !dtl::is_convertible::value && //not convertible to iterator !dtl::is_convertible::value //not convertible to const_iterator BOOST_MOVE_I size_type>::type) - erase(const K& x) + erase(BOOST_FWD_REF(K) x) { return m_flat_tree.erase_unique(x); } //! Effects: Erases all the elements in the range [first, last). diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp index dde6035..0b0f498 100644 --- a/include/boost/container/map.hpp +++ b/include/boost/container/map.hpp @@ -1032,7 +1032,7 @@ class map !dtl::is_convertible::value && //not convertible to iterator !dtl::is_convertible::value //not convertible to const_iterator BOOST_MOVE_I size_type>::type) - erase(const K& x) + erase(BOOST_FWD_REF(K) x) { return this->base_t::erase_unique(x); } #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)