diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 65bffd0b6..a302bc930 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -33,13 +33,14 @@ #include #include #include +#include #include #include #include -#include #include +#include +#include #include -#include #include #include #include @@ -66,15 +67,20 @@ namespace boost { namespace fusion template struct pure : remove_cv::type> {}; - template ::value> - struct is_convertible_to_first - : boost::is_convertible::type> - {}; - - template - struct is_convertible_to_first - : mpl::false_ - {}; + template + struct can_convert : mpl::false_ {}; + + template + struct can_convert< + Sequence + , This + , typename enable_if>::type + > : mpl::equal_to< + fusion::result_of::size + , fusion::result_of::size + > + { + }; template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -90,9 +96,8 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline from_sequence< typename lazy_enable_if_c< - (traits::is_sequence::type>::value && - !is_same::type>::value && - !is_convertible_to_first::value) + (!is_same::type>::value && + can_convert::type, This>::value) , make_indices_from_seq >::type > diff --git a/test/sequence/nest.hpp b/test/sequence/nest.hpp index e8087320f..1f6771092 100644 --- a/test/sequence/nest.hpp +++ b/test/sequence/nest.hpp @@ -7,6 +7,43 @@ #include #include +#include +#include +#include + +template class As> +void test_from_sequence_rvalue() +{ + typename As::type dst((C())); + (void)dst; +} + +template class As> +void test_from_sequence_const_lvalue() +{ + C src; + typename As::type dst(src); + (void)dst; +} + +template class As> +void test_from_sequence_lvalue() +{ + const C src; + typename As::type dst(src); + (void)dst; +} + +template class As> +void test_from_sequence() +{ +// the following tests do not work in all cases for C++03 +#if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) + test_from_sequence_rvalue(); + test_from_sequence_const_lvalue(); + test_from_sequence_lvalue(); +#endif +} template void test_copy() @@ -29,6 +66,10 @@ void test_move() template void test_all() { +// as_deque and as_list do not work in C++03 or C++11 mode +// test_from_sequence(); +// test_from_sequence(); + test_from_sequence(); test_copy(); #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) test_move(); @@ -54,5 +95,23 @@ test() test_all, int> >(); test_all > >(); test_all, float> >(); + + test_all, FUSION_SEQUENCE<> > >(); + test_all, FUSION_SEQUENCE<> > >(); + test_all, FUSION_SEQUENCE > >(); + test_all< + FUSION_SEQUENCE, FUSION_SEQUENCE > + >(); + test_all< + FUSION_SEQUENCE, FUSION_SEQUENCE > + >(); + test_all< + FUSION_SEQUENCE, FUSION_SEQUENCE > + >(); + test_all< + FUSION_SEQUENCE< + FUSION_SEQUENCE, FUSION_SEQUENCE + > + >(); }