From 280b1971b6952b8728abede914d61c4b406a7b0c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 11 Dec 2011 21:39:18 +0000 Subject: [PATCH] Unordered: merge from trunk. [SVN r75908] --- doc/changes.qbk | 5 + .../boost/unordered/detail/emplace_args.hpp | 72 ++++- include/boost/unordered/detail/equivalent.hpp | 36 ++- include/boost/unordered/detail/table.hpp | 6 +- include/boost/unordered/detail/unique.hpp | 28 +- include/boost/unordered/unordered_map.hpp | 280 ++++++++++++----- include/boost/unordered/unordered_set.hpp | 296 +++++++++++++----- test/unordered/Jamfile.v2 | 6 +- 8 files changed, 540 insertions(+), 189 deletions(-) diff --git a/doc/changes.qbk b/doc/changes.qbk index 9c4d040e..4837837c 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -170,4 +170,9 @@ C++11 support has resulted in some breaking changes: the variadic consturctors define `BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT`. +[h2 Boost 1.49.0] + +* Fix warning due to accidental odd assignment. +* Slightly better error messages. + [endsect] diff --git a/include/boost/unordered/detail/emplace_args.hpp b/include/boost/unordered/detail/emplace_args.hpp index afa3fd31..d9e5dad7 100644 --- a/include/boost/unordered/detail/emplace_args.hpp +++ b/include/boost/unordered/detail/emplace_args.hpp @@ -173,6 +173,8 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_EARGS, // // Used for piecewise construction. +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) + #define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \ template \ void construct_from_tuple(T* ptr, namespace_::tuple<>) \ @@ -206,6 +208,49 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std) #undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL #undef BOOST_UNORDERED_GET_TUPLE_ARG +#else + + template struct length {}; + + template + void construct_from_tuple_impl( + boost::unordered::detail::length<0>, T* ptr, + boost::tuple<>) + { + new ((void*) ptr) T(); + } + +#define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL(z, n, _) \ + template \ + void construct_from_tuple_impl( \ + boost::unordered::detail::length, T* ptr, \ + namespace_::tuple const& x) \ + { \ + new ((void*) ptr) T( \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_GET_TUPLE_ARG, namespace_) \ + ); \ + } + +#define BOOST_UNORDERED_GET_TUPLE_ARG(z, n, _) \ + boost::get(x) + + BOOST_PP_REPEAT_FROM_TO(1, 10, \ + BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL, _) + + template + void construct_from_tuple(T* ptr, Tuple const& x) + { + construct_from_tuple_impl( + boost::unordered::detail::length< + boost::tuples::length::value>(), + ptr, x); + } + +#undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL +#undef BOOST_UNORDERED_GET_TUPLE_ARG + +#endif + //////////////////////////////////////////////////////////////////////////// // SFINAE traits for construction. @@ -334,7 +379,32 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std) args.a)); \ } - BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, + template + inline void construct_impl(T* address, emplace_args1 const& args) + { + new((void*) address) T(boost::forward(args.a0)); + } + + template + inline void construct_impl(T* address, emplace_args2 const& args) + { + new((void*) address) T( + boost::forward(args.a0), + boost::forward(args.a1) + ); + } + + template + inline void construct_impl(T* address, emplace_args3 const& args) + { + new((void*) address) T( + boost::forward(args.a0), + boost::forward(args.a1), + boost::forward(args.a2) + ); + } + + BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_CONSTRUCT_IMPL, _) #undef BOOST_UNORDERED_CONSTRUCT_IMPL diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index 82141368..6e7e4190 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -115,20 +115,21 @@ namespace boost { namespace unordered { namespace detail { typedef typename pick::link_pointer link_pointer; }; - template + template struct multiset { - typedef boost::unordered::detail::multiset types; + typedef boost::unordered::detail::multiset types; - typedef A allocator; + typedef T value_type; typedef H hasher; typedef P key_equal; + typedef T key_type; - typedef boost::unordered::detail::allocator_traits traits; - typedef typename traits::value_type value_type; - typedef value_type key_type; + typedef typename boost::unordered::detail::rebind_wrap< + A, value_type>::type allocator; - typedef boost::unordered::detail::pick_grouped_node pick; + typedef boost::unordered::detail::allocator_traits traits; + typedef boost::unordered::detail::pick_grouped_node pick; typedef typename pick::node node; typedef typename pick::bucket bucket; typedef typename pick::link_pointer link_pointer; @@ -137,20 +138,21 @@ namespace boost { namespace unordered { namespace detail { typedef boost::unordered::detail::set_extractor extractor; }; - template + template struct multimap { - typedef boost::unordered::detail::multimap types; + typedef boost::unordered::detail::multimap types; - typedef A allocator; + typedef std::pair value_type; typedef H hasher; typedef P key_equal; typedef K key_type; - typedef boost::unordered::detail::allocator_traits traits; - typedef typename traits::value_type value_type; + typedef typename boost::unordered::detail::rebind_wrap< + A, value_type>::type allocator; - typedef boost::unordered::detail::pick_grouped_node pick; + typedef boost::unordered::detail::allocator_traits traits; + typedef boost::unordered::detail::pick_grouped_node pick; typedef typename pick::node node; typedef typename pick::bucket bucket; typedef typename pick::link_pointer link_pointer; @@ -451,22 +453,22 @@ namespace boost { namespace unordered { namespace detail { } #if defined(BOOST_NO_RVALUE_REFERENCES) - node_pointer emplace(boost::unordered::detail::emplace_args1< + iterator emplace(boost::unordered::detail::emplace_args1< boost::unordered::detail::please_ignore_this_overload> const&) { BOOST_ASSERT(false); - return this->begin(); + return iterator(); } #endif template - node_pointer emplace(BOOST_UNORDERED_EMPLACE_ARGS) + iterator emplace(BOOST_UNORDERED_EMPLACE_ARGS) { node_constructor a(this->node_alloc()); a.construct_node(); a.construct_value(BOOST_UNORDERED_EMPLACE_FORWARD); - return emplace_impl(a); + return iterator(emplace_impl(a)); } //////////////////////////////////////////////////////////////////////// diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index ed128c9a..66c46084 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -174,13 +174,13 @@ namespace boost { namespace unordered { namespace iterator_detail { } iterator& operator++() { - node_ = node_ = static_cast(node_->next_); + node_ = static_cast(node_->next_); return *this; } iterator operator++(int) { iterator tmp(node_); - node_ = node_ = static_cast(node_->next_); + node_ = static_cast(node_->next_); return tmp; } @@ -242,7 +242,7 @@ namespace boost { namespace unordered { namespace iterator_detail { c_iterator operator++(int) { c_iterator tmp(node_); - node_ = node_ = static_cast(node_->next_); + node_ = static_cast(node_->next_); return tmp; } diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 717efd39..58740fe9 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -111,20 +111,21 @@ namespace boost { namespace unordered { namespace detail { typedef typename pick::link_pointer link_pointer; }; - template + template struct set { - typedef boost::unordered::detail::set types; + typedef boost::unordered::detail::set types; - typedef A allocator; + typedef T value_type; typedef H hasher; typedef P key_equal; + typedef T key_type; - typedef boost::unordered::detail::allocator_traits traits; - typedef typename traits::value_type value_type; - typedef value_type key_type; + typedef typename boost::unordered::detail::rebind_wrap< + A, value_type>::type allocator; - typedef boost::unordered::detail::pick_node pick; + typedef boost::unordered::detail::allocator_traits traits; + typedef boost::unordered::detail::pick_node pick; typedef typename pick::node node; typedef typename pick::bucket bucket; typedef typename pick::link_pointer link_pointer; @@ -133,20 +134,21 @@ namespace boost { namespace unordered { namespace detail { typedef boost::unordered::detail::set_extractor extractor; }; - template + template struct map { - typedef boost::unordered::detail::map types; + typedef boost::unordered::detail::map types; - typedef A allocator; + typedef std::pair value_type; typedef H hasher; typedef P key_equal; typedef K key_type; - typedef boost::unordered::detail::allocator_traits traits; - typedef typename traits::value_type value_type; + typedef typename boost::unordered::detail::rebind_wrap< + A, value_type>::type allocator; - typedef boost::unordered::detail::pick_node pick; + typedef boost::unordered::detail::allocator_traits traits; + typedef boost::unordered::detail::pick_node pick; typedef typename pick::node node; typedef typename pick::bucket bucket; typedef typename pick::link_pointer link_pointer; diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index f12c84b1..6e44ed6b 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -54,15 +54,9 @@ namespace unordered private: - typedef typename boost::unordered::detail::rebind_wrap< - allocator_type, value_type>::type - value_allocator; - - typedef boost::unordered::detail::allocator_traits - allocator_traits; - - typedef boost::unordered::detail::map - types; + typedef boost::unordered::detail::map types; + typedef typename types::allocator value_allocator; + typedef typename types::traits allocator_traits; typedef typename types::table table; public: @@ -84,7 +78,7 @@ namespace unordered private: table table_; - + public: // constructors @@ -224,10 +218,105 @@ namespace unordered template iterator emplace_hint(const_iterator, Args&&... args) { - return iterator(table_.emplace(std::forward(args)...).first); + return table_.emplace(std::forward(args)...).first; } #else +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + + // 0 argument emplace requires special treatment in case + // the container is instantiated with a value type that + // doesn't have a default constructor. + + std::pair emplace( + boost::unordered::detail::empty_emplace + = boost::unordered::detail::empty_emplace(), + value_type v = value_type()) + { + return this->emplace(boost::move(v)); + } + + iterator emplace_hint(const_iterator hint, + boost::unordered::detail::empty_emplace + = boost::unordered::detail::empty_emplace(), + value_type v = value_type() + ) + { + return this->emplace_hint(hint, boost::move(v)); + } + +#endif + + template + std::pair emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ); + } + + template + iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ).first; + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ).first; + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ).first; + } + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template < \ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ @@ -251,39 +340,18 @@ namespace unordered BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ ) \ { \ - return iterator(table_.emplace( \ + return table_.emplace( \ boost::unordered::detail::create_emplace_args( \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ a) \ - )).first); \ + )).first; \ } - BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, + BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_EMPLACE, _) #undef BOOST_UNORDERED_EMPLACE -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) - - std::pair emplace( - boost::unordered::detail::empty_emplace - = boost::unordered::detail::empty_emplace(), - value_type v = value_type()) - { - return this->emplace(boost::move(v)); - } - - iterator emplace_hint(const_iterator hint, - boost::unordered::detail::empty_emplace - = boost::unordered::detail::empty_emplace(), - value_type v = value_type() - ) - { - return this->emplace_hint(hint, boost::move(v)); - } - -#endif - #endif std::pair insert(value_type const& x) @@ -446,15 +514,9 @@ namespace unordered private: - typedef typename boost::unordered::detail::rebind_wrap< - allocator_type, value_type>::type - value_allocator; - - typedef boost::unordered::detail::allocator_traits - allocator_traits; - - typedef boost::unordered::detail::multimap - types; + typedef boost::unordered::detail::multimap types; + typedef typename types::allocator value_allocator; + typedef typename types::traits allocator_traits; typedef typename types::table table; public: @@ -611,16 +673,111 @@ namespace unordered template iterator emplace(Args&&... args) { - return iterator(table_.emplace(std::forward(args)...)); + return table_.emplace(std::forward(args)...); } template iterator emplace_hint(const_iterator, Args&&... args) { - return iterator(table_.emplace(std::forward(args)...)); + return table_.emplace(std::forward(args)...); } #else +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + + // 0 argument emplace requires special treatment in case + // the container is instantiated with a value type that + // doesn't have a default constructor. + + iterator emplace( + boost::unordered::detail::empty_emplace + = boost::unordered::detail::empty_emplace(), + value_type v = value_type()) + { + return this->emplace(boost::move(v)); + } + + iterator emplace_hint(const_iterator hint, + boost::unordered::detail::empty_emplace + = boost::unordered::detail::empty_emplace(), + value_type v = value_type() + ) + { + return this->emplace_hint(hint, boost::move(v)); + } + +#endif + + template + iterator emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ); + } + + template + iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ); + } + + template + iterator emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ); + } + + template + iterator emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ); + } + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template < \ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ @@ -629,11 +786,11 @@ namespace unordered BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ ) \ { \ - return iterator(table_.emplace( \ + return table_.emplace( \ boost::unordered::detail::create_emplace_args( \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ a) \ - ))); \ + )); \ } \ \ template < \ @@ -644,39 +801,18 @@ namespace unordered BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ ) \ { \ - return iterator(table_.emplace( \ + return table_.emplace( \ boost::unordered::detail::create_emplace_args( \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ a) \ - ))); \ + )); \ } - BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, + BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_EMPLACE, _) #undef BOOST_UNORDERED_EMPLACE -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) - - iterator emplace( - boost::unordered::detail::empty_emplace - = boost::unordered::detail::empty_emplace(), - value_type v = value_type()) - { - return iterator(this->emplace(boost::move(v))); - } - - iterator emplace_hint(const_iterator hint, - boost::unordered::detail::empty_emplace - = boost::unordered::detail::empty_emplace(), - value_type v = value_type() - ) - { - return iterator(this->emplace_hint(hint, boost::move(v))); - } - -#endif - #endif iterator insert(value_type const& x) diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 227610bf..f23ea74f 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -52,15 +52,9 @@ namespace unordered private: - typedef typename boost::unordered::detail::rebind_wrap< - allocator_type, value_type>::type - value_allocator; - - typedef boost::unordered::detail::allocator_traits - allocator_traits; - - typedef boost::unordered::detail::set - types; + typedef boost::unordered::detail::set types; + typedef typename types::allocator value_allocator; + typedef typename types::traits allocator_traits; typedef typename types::table table; public: @@ -222,10 +216,105 @@ namespace unordered template iterator emplace_hint(const_iterator, Args&&... args) { - return iterator(table_.emplace(std::forward(args)...).first); + return table_.emplace(std::forward(args)...).first; } #else +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + + // 0 argument emplace requires special treatment in case + // the container is instantiated with a value type that + // doesn't have a default constructor. + + std::pair emplace( + boost::unordered::detail::empty_emplace + = boost::unordered::detail::empty_emplace(), + value_type v = value_type()) + { + return this->emplace(boost::move(v)); + } + + iterator emplace_hint(const_iterator hint, + boost::unordered::detail::empty_emplace + = boost::unordered::detail::empty_emplace(), + value_type v = value_type() + ) + { + return this->emplace_hint(hint, boost::move(v)); + } + +#endif + + template + std::pair emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ); + } + + template + iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ).first; + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ).first; + } + + template + std::pair emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ).first; + } + #define BOOST_UNORDERED_EMPLACE(z, n, _) \ template < \ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ @@ -249,39 +338,18 @@ namespace unordered BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ ) \ { \ - return iterator(table_.emplace( \ + return table_.emplace( \ boost::unordered::detail::create_emplace_args( \ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ a) \ - )).first); \ + )).first; \ } - BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, + BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_EMPLACE, _) #undef BOOST_UNORDERED_EMPLACE -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) - - std::pair emplace( - boost::unordered::detail::empty_emplace - = boost::unordered::detail::empty_emplace(), - value_type v = value_type()) - { - return this->emplace(boost::move(v)); - } - - iterator emplace_hint(const_iterator hint, - boost::unordered::detail::empty_emplace - = boost::unordered::detail::empty_emplace(), - value_type v = value_type() - ) - { - return iterator(this->emplace_hint(hint, boost::move(v))); - } - -#endif - #endif std::pair insert(value_type const& x) @@ -429,15 +497,9 @@ namespace unordered private: - typedef typename boost::unordered::detail::rebind_wrap< - allocator_type, value_type>::type - value_allocator; - - typedef boost::unordered::detail::allocator_traits - allocator_traits; - - typedef boost::unordered::detail::multiset - types; + typedef boost::unordered::detail::multiset types; + typedef typename types::allocator value_allocator; + typedef typename types::traits allocator_traits; typedef typename types::table table; public: @@ -594,53 +656,22 @@ namespace unordered template iterator emplace(Args&&... args) { - return iterator(table_.emplace(std::forward(args)...)); + return table_.emplace(std::forward(args)...); } template iterator emplace_hint(const_iterator, Args&&... args) { - return iterator(table_.emplace(std::forward(args)...)); + return table_.emplace(std::forward(args)...); } #else -#define BOOST_UNORDERED_EMPLACE(z, n, _) \ - template < \ - BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ - > \ - iterator emplace( \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ - ) \ - { \ - return iterator(table_.emplace( \ - boost::unordered::detail::create_emplace_args( \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ - a) \ - ))); \ - } \ - \ - template < \ - BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ - > \ - iterator emplace_hint( \ - const_iterator, \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ - ) \ - { \ - return iterator(table_.emplace( \ - boost::unordered::detail::create_emplace_args( \ - BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ - a) \ - ))); \ - } - - BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, - BOOST_UNORDERED_EMPLACE, _) - -#undef BOOST_UNORDERED_EMPLACE - #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) + // 0 argument emplace requires special treatment in case + // the container is instantiated with a value type that + // doesn't have a default constructor. + iterator emplace( boost::unordered::detail::empty_emplace = boost::unordered::detail::empty_emplace(), @@ -660,6 +691,111 @@ namespace unordered #endif + template + iterator emplace(BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ); + } + + template + iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0)) + ); + } + + template + iterator emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1)) + ); + } + + template + iterator emplace( + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ); + } + + template + iterator emplace_hint(const_iterator, + BOOST_FWD_REF(A0) a0, + BOOST_FWD_REF(A1) a1, + BOOST_FWD_REF(A2) a2) + { + return table_.emplace( + boost::unordered::detail::create_emplace_args( + boost::forward(a0), + boost::forward(a1), + boost::forward(a2)) + ); + } + +#define BOOST_UNORDERED_EMPLACE(z, n, _) \ + template < \ + BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ + > \ + iterator emplace( \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ + ) \ + { \ + return table_.emplace( \ + boost::unordered::detail::create_emplace_args( \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ + a) \ + )); \ + } \ + \ + template < \ + BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ + > \ + iterator emplace_hint( \ + const_iterator, \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \ + ) \ + { \ + return table_.emplace( \ + boost::unordered::detail::create_emplace_args( \ + BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \ + a) \ + )); \ + } + + BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT, + BOOST_UNORDERED_EMPLACE, _) + +#undef BOOST_UNORDERED_EMPLACE + #endif iterator insert(value_type const& x) diff --git a/test/unordered/Jamfile.v2 b/test/unordered/Jamfile.v2 index 1a86a742..de9c2ed9 100644 --- a/test/unordered/Jamfile.v2 +++ b/test/unordered/Jamfile.v2 @@ -9,13 +9,13 @@ project unordered-test/unordered : requirements all intel:on - gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion" + gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wno-long-long" darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion" #gcc:_GLIBCXX_DEBUG #darwin:_GLIBCXX_DEBUG #msvc:on - #gcc:on - #darwin:on + gcc:on + darwin:on ; test-suite unordered