From fab3df0a04f6b84f0c1c3f9bc6ebbfc803dd9614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 3 Aug 2014 11:09:54 +0200 Subject: [PATCH] Added emplace optimization specializations for compilers with rvalue references but without variadic templates (e.g. MSVC10&11) --- .../container/detail/advanced_insert_int.hpp | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index 4d00d7a..1296659 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -386,6 +386,8 @@ struct BOOST_PP_CAT(insert_emplace_proxy_arg, N) #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) #include BOOST_PP_LOCAL_ITERATE() +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type template struct insert_emplace_proxy_arg1::value_type> > @@ -404,7 +406,37 @@ struct insert_emplace_proxy_arg1(v) {} }; -/* + +#else //e.g. MSVC10 & MSVC11 + +//Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type +template +struct insert_emplace_proxy_arg1::value_type> + : public insert_move_proxy +{ + explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &&v) + : insert_move_proxy(v) + {} +}; + +template +struct insert_emplace_proxy_arg1::value_type &> + : public insert_copy_proxy +{ + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) + {} +}; + +template +struct insert_emplace_proxy_arg1::value_type &> + : public insert_copy_proxy +{ + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) + {} +}; + template struct insert_emplace_proxy_arg1::value_type> : public insert_copy_proxy @@ -413,7 +445,9 @@ struct insert_emplace_proxy_arg1(v) {} }; -*/ + +#endif + }}} //namespace boost { namespace container { namespace container_detail { #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING