From ca018bfba658bcdead1ea7b3c25ba75b71f57dad Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 23 Jul 2009 17:53:59 +0000 Subject: [PATCH] Remove the emulation of single argument C++0x std::pair constructor. [SVN r55132] --- .../unordered/detail/hash_table_impl.hpp | 64 +++---------------- test/helpers/input_iterator.hpp | 19 +++++- 2 files changed, 25 insertions(+), 58 deletions(-) diff --git a/include/boost/unordered/detail/hash_table_impl.hpp b/include/boost/unordered/detail/hash_table_impl.hpp index cee3e051..6bfe6580 100644 --- a/include/boost/unordered/detail/hash_table_impl.hpp +++ b/include/boost/unordered/detail/hash_table_impl.hpp @@ -206,55 +206,6 @@ namespace boost { new(node_->address()) value_type(std::forward(args)...); value_constructed_ = true; } - -#if defined(__GLIBCPP__) || defined(__GLIBCXX__) - // The GCC C++0x standard library implementation does not have - // a single argument pair constructor, so this works around that. - - template - void construct(Arg&& arg) - { - construct_preamble(); - construct_impl(std::forward(arg), - (value_type const*) 0, - (typename boost::remove_reference::type const*) 0); - value_constructed_ = true; - } - - template < - typename Arg, - typename ValueType, - typename Type> - void construct_impl(Arg&& arg, ValueType const*, Type const*) - { - new(node_->address()) value_type(std::forward(arg)); - } - - template < - typename Arg, - typename ValueFirst, typename ValueSecond, - typename TypeFirst, typename TypeSecond> - void construct_impl( - Arg&& arg, - std::pair const*, - std::pair const*) - { - new(node_->address()) value_type(std::forward(arg)); - } - - template < - typename Arg, - typename ValueFirst, typename ValueSecond, - typename Type> - void construct_impl( - Arg&& arg, - std::pair const*, - Type const*) - { - new(node_->address()) value_type(std::forward(arg), ValueSecond()); - } -#endif - #else #define BOOST_UNORDERED_CONSTRUCT_IMPL(z, n, _) \ @@ -316,15 +267,16 @@ namespace boost { new(node_->address()) value_type(arg0); } - template - void construct_impl(std::pair*, Key const& k) - { - new(node_->address()) value_type(First(k), Second()); - } - #undef BOOST_UNORDERED_CONSTRUCT_IMPL #endif + template + void construct_pair(K const& k, M*) + { + construct_preamble(); + new(node_->address()) value_type(k, M()); + value_constructed_ = true; + } node_ptr get() const { @@ -1922,7 +1874,7 @@ namespace boost { // Create the node before rehashing in case it throws an // exception (need strong safety in such a case). node_constructor a(data_.allocators_); - a.construct(k); + a.construct_pair(k, (mapped_type*) 0); // reserve has basic exception safety if the hash function // throws, strong otherwise. diff --git a/test/helpers/input_iterator.hpp b/test/helpers/input_iterator.hpp index ec864b7e..d81d9fec 100644 --- a/test/helpers/input_iterator.hpp +++ b/test/helpers/input_iterator.hpp @@ -6,19 +6,34 @@ #if !defined(BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER) #define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER +#include #include namespace test { + template + struct proxy + { + typedef BOOST_DEDUCED_TYPENAME Iterator::value_type value_type; + + proxy(value_type const& v) : v_(v) {} + proxy(proxy const& x) : v_(x.v_) {} + operator value_type const&() const { return v_; } + + value_type v_; + }; + template struct input_iterator_adaptor : boost::iterator_adaptor< input_iterator_adaptor, Iterator, - boost::use_default, std::input_iterator_tag> + boost::use_default, std::input_iterator_tag, + proxy > { typedef boost::iterator_adaptor< input_iterator_adaptor, Iterator, - boost::use_default, std::input_iterator_tag> base; + boost::use_default, std::input_iterator_tag, + proxy > base; explicit input_iterator_adaptor(Iterator it = Iterator()) : base(it) {}