diff --git a/include/boost/unordered/detail/fwd.hpp b/include/boost/unordered/detail/fwd.hpp index c8a4abc7..39f85427 100644 --- a/include/boost/unordered/detail/fwd.hpp +++ b/include/boost/unordered/detail/fwd.hpp @@ -629,30 +629,18 @@ namespace boost { namespace unordered_detail { template emplace_return emplace(Args&&... args); template - iterator_base emplace_hint(iterator_base const&, Args&&... args); - template emplace_return emplace_impl(key_type const& k, Args&&... args); template emplace_return emplace_impl(no_key, Args&&... args); template emplace_return emplace_empty_impl(Args&&... args); #else - template - emplace_return emplace(Arg0 const& arg0); - template - iterator_base emplace_hint(iterator_base const&, Arg0 const& arg0); #define BOOST_UNORDERED_INSERT_IMPL(z, n, _) \ template \ emplace_return emplace( \ BOOST_UNORDERED_FUNCTION_PARAMS(z, n)); \ template \ - iterator_base emplace_hint(iterator_base const& it, \ - BOOST_UNORDERED_FUNCTION_PARAMS(z, n)); \ - BOOST_UNORDERED_INSERT_IMPL2(z, n, _) - -#define BOOST_UNORDERED_INSERT_IMPL2(z, n, _) \ - template \ emplace_return emplace_impl(key_type const& k, \ BOOST_UNORDERED_FUNCTION_PARAMS(z, n)); \ template \ @@ -662,13 +650,10 @@ namespace boost { namespace unordered_detail { emplace_return emplace_empty_impl( \ BOOST_UNORDERED_FUNCTION_PARAMS(z, n)); - BOOST_UNORDERED_INSERT_IMPL2(1, 1, _) - - BOOST_PP_REPEAT_FROM_TO(2, BOOST_UNORDERED_EMPLACE_LIMIT, + BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_INSERT_IMPL, _) #undef BOOST_UNORDERED_INSERT_IMPL -#undef BOOST_UNORDERED_INSERT_IMPL2 #endif diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 14565bca..b4a5157c 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -272,25 +272,6 @@ namespace boost { namespace unordered_detail { emplace_empty_impl(std::forward(args)...); } - // Insert (unique keys) - // (I'm using an overloaded emplace for both 'insert' and 'emplace') - // I'm just ignoring hints here for now. - - // if hash function throws, basic exception safety - // strong otherwise - template - template - BOOST_DEDUCED_TYPENAME hash_unique_table::iterator_base - hash_unique_table::emplace_hint(iterator_base const&, - Args&&... args) - { - return this->size_ ? - emplace_impl( - extractor::extract(std::forward(args)...), - std::forward(args)...).first : - emplace_empty_impl(std::forward(args)...).first; - } - #else template @@ -303,17 +284,6 @@ namespace boost { namespace unordered_detail { emplace_empty_impl(arg0); } - template - template - BOOST_DEDUCED_TYPENAME hash_unique_table::iterator_base - hash_unique_table::emplace_hint(iterator_base const&, - Arg0 const& arg0) - { - return this->size_ ? - emplace_impl(extractor::extract(arg0), arg0).first : - emplace_empty_impl(arg0).first; - } - #define BOOST_UNORDERED_INSERT_IMPL(z, num_params, _) \ template \ template \ @@ -326,21 +296,7 @@ namespace boost { namespace unordered_detail { BOOST_UNORDERED_CALL_PARAMS(z, num_params)) : \ emplace_empty_impl( \ BOOST_UNORDERED_CALL_PARAMS(z, num_params)); \ - } \ - \ - template \ - template \ - BOOST_DEDUCED_TYPENAME hash_unique_table::iterator_base \ - hash_unique_table:: \ - emplace_hint(iterator_base const& it, \ - BOOST_UNORDERED_FUNCTION_PARAMS(z, num_params)) \ - { \ - return this->size_ ? \ - emplace_impl(extractor::extract(arg0, arg1), \ - BOOST_UNORDERED_CALL_PARAMS(z, num_params)) : \ - emplace_empty_impl( \ - BOOST_UNORDERED_CALL_PARAMS(z, num_params)); \ - } \ + } BOOST_PP_REPEAT_FROM_TO(2, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_INSERT_IMPL, _) diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 0e89d43a..f4c052f5 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -277,10 +277,9 @@ namespace boost } template - iterator emplace_hint(const_iterator hint, Args&&... args) + iterator emplace_hint(const_iterator, Args&&... args) { - return iterator( - table_.emplace_hint(get(hint), std::forward(args)...)); + return iterator(table_.emplace(std::forward(args)...).first); } #else @@ -290,10 +289,9 @@ namespace boost table_.emplace(v)); } - iterator emplace_hint(const_iterator hint, - value_type const& v = value_type()) + iterator emplace_hint(const_iterator, value_type const& v = value_type()) { - return iterator(table_.emplace_hint(get(hint), v)); + return iterator(table_.emplace(v).first); } #define BOOST_UNORDERED_EMPLACE(z, n, _) \ @@ -317,9 +315,8 @@ namespace boost BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \ ) \ { \ - return iterator(table_.emplace_hint(get(hint), \ - BOOST_UNORDERED_CALL_PARAMS(z, n) \ - )); \ + return iterator(table_.emplace( \ + BOOST_UNORDERED_CALL_PARAMS(z, n)).first); \ } BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, @@ -337,7 +334,7 @@ namespace boost iterator insert(const_iterator hint, const value_type& obj) { - return iterator(table_.emplace_hint(get(hint), obj)); + return iterator(table_.emplace(obj).first); } template diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index e7d53d23..2b147b28 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -270,10 +270,9 @@ namespace boost } template - iterator emplace_hint(const_iterator hint, Args&&... args) + iterator emplace_hint(const_iterator, Args&&... args) { - return iterator( - table_.emplace_hint(get(hint), std::forward(args)...)); + return iterator(table_.emplace(std::forward(args)...).first); } #else @@ -283,10 +282,10 @@ namespace boost table_.emplace(v)); } - iterator emplace_hint(const_iterator hint, + iterator emplace_hint(const_iterator, value_type const& v = value_type()) { - return iterator(table_.emplace_hint(get(hint), v)); + return iterator(table_.emplace(v).first); } #define BOOST_UNORDERED_EMPLACE(z, n, _) \ @@ -306,13 +305,12 @@ namespace boost template < \ BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \ > \ - iterator emplace_hint(const_iterator hint, \ + iterator emplace_hint(const_iterator, \ BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \ ) \ { \ - return iterator(table_.emplace_hint(get(hint), \ - BOOST_UNORDERED_CALL_PARAMS(z, n) \ - )); \ + return iterator(table_.emplace( \ + BOOST_UNORDERED_CALL_PARAMS(z, n)).first); \ } BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, @@ -330,7 +328,7 @@ namespace boost iterator insert(const_iterator hint, const value_type& obj) { - return iterator(table_.emplace_hint(get(hint), obj)); + return iterator(table_.emplace(obj).first); } template