Remove the emulation of single argument C++0x std::pair constructor.

[SVN r55132]
This commit is contained in:
Daniel James
2009-07-23 17:53:59 +00:00
parent 3c48fa3818
commit ca018bfba6
2 changed files with 25 additions and 58 deletions

View File

@ -206,55 +206,6 @@ namespace boost {
new(node_->address()) value_type(std::forward<Args>(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 <typename Arg>
void construct(Arg&& arg)
{
construct_preamble();
construct_impl(std::forward<Arg>(arg),
(value_type const*) 0,
(typename boost::remove_reference<Arg>::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>(arg));
}
template <
typename Arg,
typename ValueFirst, typename ValueSecond,
typename TypeFirst, typename TypeSecond>
void construct_impl(
Arg&& arg,
std::pair<ValueFirst, ValueSecond> const*,
std::pair<TypeFirst, TypeSecond> const*)
{
new(node_->address()) value_type(std::forward<Arg>(arg));
}
template <
typename Arg,
typename ValueFirst, typename ValueSecond,
typename Type>
void construct_impl(
Arg&& arg,
std::pair<ValueFirst, ValueSecond> const*,
Type const*)
{
new(node_->address()) value_type(std::forward<Arg>(arg), ValueSecond());
}
#endif
#else
#define BOOST_UNORDERED_CONSTRUCT_IMPL(z, n, _) \
@ -316,15 +267,16 @@ namespace boost {
new(node_->address()) value_type(arg0);
}
template <typename First, typename Second, typename Key>
void construct_impl(std::pair<First, Second>*, Key const& k)
{
new(node_->address()) value_type(First(k), Second());
}
#undef BOOST_UNORDERED_CONSTRUCT_IMPL
#endif
template <typename K, typename M>
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.

View File

@ -6,19 +6,34 @@
#if !defined(BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER)
#define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER
#include <boost/config.hpp>
#include <boost/iterator_adaptors.hpp>
namespace test
{
template <class Iterator>
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 <class Iterator>
struct input_iterator_adaptor
: boost::iterator_adaptor<
input_iterator_adaptor<Iterator>, Iterator,
boost::use_default, std::input_iterator_tag>
boost::use_default, std::input_iterator_tag,
proxy<Iterator> >
{
typedef boost::iterator_adaptor<
input_iterator_adaptor<Iterator>, Iterator,
boost::use_default, std::input_iterator_tag> base;
boost::use_default, std::input_iterator_tag,
proxy<Iterator> > base;
explicit input_iterator_adaptor(Iterator it = Iterator())
: base(it) {}