mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-21 16:22:45 +02:00
Added to nested tests, and fixed C++11 vector copy-from-sequence
This commit is contained in:
@ -33,13 +33,14 @@
|
|||||||
#include <boost/fusion/container/vector/detail/end_impl.hpp>
|
#include <boost/fusion/container/vector/detail/end_impl.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
#include <boost/fusion/iterator/advance.hpp>
|
#include <boost/fusion/iterator/advance.hpp>
|
||||||
#include <boost/fusion/iterator/deref.hpp>
|
#include <boost/fusion/iterator/deref.hpp>
|
||||||
#include <boost/core/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
#include <boost/mpl/int.hpp>
|
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
|
#include <boost/mpl/equal_to.hpp>
|
||||||
|
#include <boost/mpl/int.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
|
||||||
#include <boost/type_traits/remove_cv.hpp>
|
#include <boost/type_traits/remove_cv.hpp>
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -66,15 +67,20 @@ namespace boost { namespace fusion
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct pure : remove_cv<typename remove_reference<T>::type> {};
|
struct pure : remove_cv<typename remove_reference<T>::type> {};
|
||||||
|
|
||||||
template <typename Sequence, typename This, int = result_of::size<This>::value>
|
template<typename Sequence, typename This, typename Enable = void>
|
||||||
struct is_convertible_to_first
|
struct can_convert : mpl::false_ {};
|
||||||
: boost::is_convertible<Sequence, typename result_of::value_at_c<This, 0>::type>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename Sequence, typename This>
|
template<typename Sequence, typename This>
|
||||||
struct is_convertible_to_first<Sequence, This, 0>
|
struct can_convert<
|
||||||
: mpl::false_
|
Sequence
|
||||||
{};
|
, This
|
||||||
|
, typename enable_if<traits::is_sequence<Sequence>>::type
|
||||||
|
> : mpl::equal_to<
|
||||||
|
fusion::result_of::size<Sequence>
|
||||||
|
, fusion::result_of::size<This>
|
||||||
|
>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
template <typename This, typename ...T>
|
template <typename This, typename ...T>
|
||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
@ -90,9 +96,8 @@ namespace boost { namespace fusion
|
|||||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||||
inline from_sequence<
|
inline from_sequence<
|
||||||
typename lazy_enable_if_c<
|
typename lazy_enable_if_c<
|
||||||
(traits::is_sequence<typename remove_reference<Sequence>::type>::value &&
|
(!is_same<This, typename pure<Sequence>::type>::value &&
|
||||||
!is_same<This, typename pure<Sequence>::type>::value &&
|
can_convert<typename pure<Sequence>::type, This>::value)
|
||||||
!is_convertible_to_first<Sequence, This>::value)
|
|
||||||
, make_indices_from_seq<Sequence>
|
, make_indices_from_seq<Sequence>
|
||||||
>::type
|
>::type
|
||||||
>
|
>
|
||||||
|
@ -7,6 +7,43 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/fusion/include/as_deque.hpp>
|
||||||
|
#include <boost/fusion/include/as_list.hpp>
|
||||||
|
#include <boost/fusion/include/as_vector.hpp>
|
||||||
|
|
||||||
|
template<typename C, template<typename> class As>
|
||||||
|
void test_from_sequence_rvalue()
|
||||||
|
{
|
||||||
|
typename As<C>::type dst((C()));
|
||||||
|
(void)dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename C, template<typename> class As>
|
||||||
|
void test_from_sequence_const_lvalue()
|
||||||
|
{
|
||||||
|
C src;
|
||||||
|
typename As<C>::type dst(src);
|
||||||
|
(void)dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename C, template<typename> class As>
|
||||||
|
void test_from_sequence_lvalue()
|
||||||
|
{
|
||||||
|
const C src;
|
||||||
|
typename As<C>::type dst(src);
|
||||||
|
(void)dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename C, template<typename> 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<C, As>();
|
||||||
|
test_from_sequence_const_lvalue<C, As>();
|
||||||
|
test_from_sequence_lvalue<C, As>();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
template <typename C>
|
template <typename C>
|
||||||
void test_copy()
|
void test_copy()
|
||||||
@ -29,6 +66,10 @@ void test_move()
|
|||||||
template <typename C>
|
template <typename C>
|
||||||
void test_all()
|
void test_all()
|
||||||
{
|
{
|
||||||
|
// as_deque and as_list do not work in C++03 or C++11 mode
|
||||||
|
// test_from_sequence<C, boost::fusion::result_of::as_deque>();
|
||||||
|
// test_from_sequence<C, boost::fusion::result_of::as_list>();
|
||||||
|
test_from_sequence<C, boost::fusion::result_of::as_vector>();
|
||||||
test_copy<C>();
|
test_copy<C>();
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
test_move<C>();
|
test_move<C>();
|
||||||
@ -54,5 +95,23 @@ test()
|
|||||||
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int, float>, int> >();
|
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int, float>, int> >();
|
||||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, float> > >();
|
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, float> > >();
|
||||||
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, float>, float> >();
|
test_all<FUSION_SEQUENCE<int, FUSION_SEQUENCE<int, float>, float> >();
|
||||||
|
|
||||||
|
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<>, FUSION_SEQUENCE<> > >();
|
||||||
|
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<> > >();
|
||||||
|
test_all<FUSION_SEQUENCE<FUSION_SEQUENCE<>, FUSION_SEQUENCE<int> > >();
|
||||||
|
test_all<
|
||||||
|
FUSION_SEQUENCE<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<float> >
|
||||||
|
>();
|
||||||
|
test_all<
|
||||||
|
FUSION_SEQUENCE<FUSION_SEQUENCE<int, float>, FUSION_SEQUENCE<float> >
|
||||||
|
>();
|
||||||
|
test_all<
|
||||||
|
FUSION_SEQUENCE<FUSION_SEQUENCE<int>, FUSION_SEQUENCE<float, int> >
|
||||||
|
>();
|
||||||
|
test_all<
|
||||||
|
FUSION_SEQUENCE<
|
||||||
|
FUSION_SEQUENCE<int, float>, FUSION_SEQUENCE<float, int>
|
||||||
|
>
|
||||||
|
>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user