diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 6291c3dc..4cd2ebe7 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -563,12 +563,10 @@ template class unordered_map iterator try_emplace(const_iterator hint, key_type const& k, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) { - return table_ - .try_emplace_unique( - hint, k, boost::unordered::detail::create_emplace_args( - boost::forward(a0), boost::forward(a1), - boost::forward(a2))) - .first; + return table_.try_emplace_hint_unique( + hint, k, boost::unordered::detail::create_emplace_args( + boost::forward(a0), boost::forward(a1), + boost::forward(a2))); } // try_emplace(key&&, Args&&...) diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index a53f43c3..b5c2fffb 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -1172,6 +1172,23 @@ UNORDERED_AUTO_TEST(map_emplace_test2) BOOST_TEST(x.find(overloaded_constructor(2, 3)) != x.end() && x.find(overloaded_constructor(2, 3))->second == overloaded_constructor(4, 5, 6)); + + x.clear(); + + x.try_emplace(x.begin(), overloaded_constructor()); + BOOST_TEST(x.find(overloaded_constructor()) != x.end() && + x.find(overloaded_constructor())->second == + overloaded_constructor()); + + x.try_emplace(x.end(), 1); + BOOST_TEST(x.find(overloaded_constructor(1)) != x.end() && + x.find(overloaded_constructor(1))->second == + overloaded_constructor()); + + x.try_emplace(x.begin(), overloaded_constructor(2, 3), 4, 5, 6); + BOOST_TEST(x.find(overloaded_constructor(2, 3)) != x.end() && + x.find(overloaded_constructor(2, 3))->second == + overloaded_constructor(4, 5, 6)); } {