From 4e57acbce743916645c333e6f119a960e64f3484 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 23 Mar 2018 02:26:05 +0900 Subject: [PATCH] Make fusion::pair trivially copyable if possible --- include/boost/fusion/support/pair.hpp | 55 ++++++++++++--------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/include/boost/fusion/support/pair.hpp b/include/boost/fusion/support/pair.hpp index a4cd1ff0..0bf2a110 100644 --- a/include/boost/fusion/support/pair.hpp +++ b/include/boost/fusion/support/pair.hpp @@ -8,15 +8,16 @@ #if !defined(FUSION_PAIR_07222005_1203) #define FUSION_PAIR_07222005_1203 -#include #include - +#include +#include #include #include -#include -#include +#include +#include +#include #include -#include +#include #if defined (BOOST_MSVC) # pragma warning(push) @@ -33,54 +34,46 @@ namespace boost { namespace fusion pair() : second() {} - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - pair(pair const& rhs) - : second(rhs.second) {} - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - pair(pair&& rhs) - : second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {} -#endif - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED pair(typename detail::call_param::type val) : second(val) {} #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template BOOST_FUSION_GPU_ENABLED - pair(Second2&& val - , typename boost::disable_if >::type* /* dummy */ = 0 - , typename boost::enable_if >::type* /*dummy*/ = 0 - ) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {} + pair(typename remove_cv_ref::type&& val) + : second(BOOST_FUSION_FWD_ELEM(Second, val)) {} #endif template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - pair(pair const& rhs) + pair(pair const& rhs, + typename disable_if, detail::enabler_>::type = detail::enabler, + typename enable_if, detail::enabler_>::type = detail::enabler) : second(rhs.second) {} template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - pair& operator=(pair const& rhs) - { - second = rhs.second; - return *this; - } - - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - pair& operator=(pair const& rhs) + typename disable_if, pair&>::type + operator=(pair const& rhs) { second = rhs.second; return *this; } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + pair(pair&& rhs, + typename disable_if, detail::enabler_>::type = detail::enabler, + typename enable_if, detail::enabler_>::type = detail::enabler) + : second(std::move(rhs.second)) {} + + template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - pair& operator=(pair&& rhs) + typename disable_if, pair&>::type + operator=(pair&& rhs) { - second = BOOST_FUSION_FWD_ELEM(Second, rhs.second); + second = std::move(rhs.second); return *this; } #endif