mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-17 22:32:15 +02:00
Fix for fusion pair to make the compiler select the proper copy
constructor and remove a viable, but wrong, constructor. test added.
This commit is contained in:
@ -37,9 +37,11 @@ namespace boost { namespace fusion
|
|||||||
: second(rhs.second) {}
|
: second(rhs.second) {}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
|
||||||
BOOST_FUSION_GPU_ENABLED
|
BOOST_FUSION_GPU_ENABLED
|
||||||
pair(pair&& rhs)
|
pair(pair&& rhs)
|
||||||
: second(std::forward<Second>(rhs.second)) {}
|
: second(std::forward<Second>(rhs.second)) {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_FUSION_GPU_ENABLED
|
BOOST_FUSION_GPU_ENABLED
|
||||||
@ -50,7 +52,7 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
template <typename Second2>
|
template <typename Second2>
|
||||||
BOOST_FUSION_GPU_ENABLED
|
BOOST_FUSION_GPU_ENABLED
|
||||||
pair(Second2&& val
|
explicit pair(Second2&& val
|
||||||
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
|
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
|
||||||
) : second(std::forward<Second2>(val)) {}
|
) : second(std::forward<Second2>(val)) {}
|
||||||
|
|
||||||
|
@ -25,6 +25,19 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
struct copy_all
|
||||||
|
{
|
||||||
|
copy_all() {}
|
||||||
|
copy_all(copy_all const&) {}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
copy_all(T const& x)
|
||||||
|
{
|
||||||
|
foo(x); // should fail!
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
@ -120,6 +133,13 @@ main()
|
|||||||
BOOST_TEST(at_key<int>(make_map<char, int>('X', 123)) == 123);
|
BOOST_TEST(at_key<int>(make_map<char, int>('X', 123)) == 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// test for copy construction of fusion pairs
|
||||||
|
// make sure that the correct constructor is called
|
||||||
|
pair<int, copy_all> p1;
|
||||||
|
pair<int, copy_all> p2 = p1;
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user