diff --git a/include/boost/unordered/detail/allocate.hpp b/include/boost/unordered/detail/allocate.hpp index 54c038d4..3084edc2 100644 --- a/include/boost/unordered/detail/allocate.hpp +++ b/include/boost/unordered/detail/allocate.hpp @@ -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)... +#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, _) \ diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index c293b72f..85681a68 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -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)); -# else + boost::unordered::detail::construct_node(alloc_, boost::addressof(*node_), - boost::unordered::detail::create_emplace_args( - boost::forward(a0))); -# endif + BOOST_UNORDERED_EMPLACE_ARGS1(boost::forward(a0))); + constructed_ = true; node_->init(static_cast(node_)); } diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 2bf55592..e7777183 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -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);