From f3fa7a1dc62aa5e7e60d1395b76ec7f08949820c Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Sat, 15 Nov 2014 09:35:50 +0800 Subject: [PATCH] Fix for fusion pair to make the compiler select the proper copy constructor and remove a viable, but wrong, constructor. test added. --- include/boost/fusion/support/pair.hpp | 4 +++- test/sequence/map.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/boost/fusion/support/pair.hpp b/include/boost/fusion/support/pair.hpp index c547926e..97cac3c7 100644 --- a/include/boost/fusion/support/pair.hpp +++ b/include/boost/fusion/support/pair.hpp @@ -37,9 +37,11 @@ namespace boost { namespace fusion : second(rhs.second) {} #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + BOOST_FUSION_GPU_ENABLED pair(pair&& rhs) : second(std::forward(rhs.second)) {} + #endif BOOST_FUSION_GPU_ENABLED @@ -50,7 +52,7 @@ namespace boost { namespace fusion template BOOST_FUSION_GPU_ENABLED - pair(Second2&& val + explicit pair(Second2&& val , typename boost::enable_if >::type* /*dummy*/ = 0 ) : second(std::forward(val)) {} diff --git a/test/sequence/map.cpp b/test/sequence/map.cpp index 58497b44..925d6720 100644 --- a/test/sequence/map.cpp +++ b/test/sequence/map.cpp @@ -25,6 +25,19 @@ #include #include + +struct copy_all +{ + copy_all() {} + copy_all(copy_all const&) {} + + template + copy_all(T const& x) + { + foo(x); // should fail! + } +}; + int main() { @@ -119,6 +132,13 @@ main() BOOST_TEST(at_key(make_map('X', 123)) == 'X'); BOOST_TEST(at_key(make_map('X', 123)) == 123); } + + { + // test for copy construction of fusion pairs + // make sure that the correct constructor is called + pair p1; + pair p2 = p1; + } return boost::report_errors(); }