Unordered: Macro to simplifiy variadic/emplace_args creation.

[SVN r79351]
This commit is contained in:
Daniel James
2012-07-08 11:53:16 +00:00
parent 68edec9f97
commit b8d96be8f7
3 changed files with 16 additions and 17 deletions

View File

@ -91,6 +91,10 @@ namespace boost { namespace unordered { namespace detail {
#define BOOST_UNORDERED_EMPLACE_ARGS BOOST_FWD_REF(Args)... args
#define BOOST_UNORDERED_EMPLACE_FORWARD boost::forward<Args>(args)...
#define BOOST_UNORDERED_EMPLACE_ARGS1(a0) a0
#define BOOST_UNORDERED_EMPLACE_ARGS2(a0, a1) a0, a1
#define BOOST_UNORDERED_EMPLACE_ARGS3(a0, a1, a2) a0, a1, a2
#else
#define BOOST_UNORDERED_EMPLACE_TEMPLATE typename Args
@ -128,6 +132,10 @@ namespace boost { namespace unordered { namespace detail {
return e; \
}
#define BOOST_UNORDERED_EMPLACE_ARGS1 create_emplace_args
#define BOOST_UNORDERED_EMPLACE_ARGS2 create_emplace_args
#define BOOST_UNORDERED_EMPLACE_ARGS3 create_emplace_args
#if defined(BOOST_NO_RVALUE_REFERENCES)
#define BOOST_UNORDERED_EARGS_MEMBER(z, n, _) \

View File

@ -82,15 +82,11 @@ namespace boost { namespace unordered { namespace detail {
void construct_value2(BOOST_FWD_REF(A0) a0)
{
BOOST_ASSERT(node_ && !constructed_);
# if !defined(BOOST_NO_VARIADIC_TEMPLATES)
boost::unordered::detail::construct_node(alloc_,
boost::addressof(*node_), boost::forward<A0>(a0));
# else
boost::unordered::detail::construct_node(alloc_,
boost::addressof(*node_),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
# endif
BOOST_UNORDERED_EMPLACE_ARGS1(boost::forward<A0>(a0)));
constructed_ = true;
node_->init(static_cast<typename node::link_pointer>(node_));
}

View File

@ -379,16 +379,11 @@ namespace boost { namespace unordered { namespace detail {
// exception (need strong safety in such a case).
node_constructor a(this->node_alloc());
a.construct_node();
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
a.construct_value(boost::unordered::piecewise_construct,
boost::make_tuple(k), boost::make_tuple());
#else
a.construct_value(
boost::unordered::detail::create_emplace_args(
boost::unordered::piecewise_construct,
boost::make_tuple(k),
boost::make_tuple()));
#endif
a.construct_value(BOOST_UNORDERED_EMPLACE_ARGS3(
boost::unordered::piecewise_construct,
boost::make_tuple(k),
boost::make_tuple()));
this->reserve_for_insert(this->size_ + 1);
return *add_node(a, key_hash);